Access97 Variables in place of fields Archived to Disk
Someone please help, I am trying to use a variable to open fields in a recordset, ie.
Dim dbs As DATABASE, rst As Recordset, strSQL As String, strFieldName as string, strWhatever as string
strFieldName = "SomeField"
Set dbs = CurrentDb
strSQL = "SELECT * FROM ATABLE"
Set rst = dbs.OpenRecordset(strSQL)
strWhatever = rst!strFieldName
I've tried all manner of ways to get this to work but it just won't replace the strFieldName with the variable value, it keeps looking for that as the field.
There's probably a better way of going about it, I just can't see it
23-05-2002 at 09:52 AM
|
JLRodgers Level: Moderator Registered: 04-04-2002 Posts: 1617
Re: Access97 Variables in place of fields Archived to Disk
Try:
rst.Fields(strFieldname)
23-05-2002 at 08:34 PM
|
dbased Level: Guest
Re: Access97 Variables in place of fields Archived to Disk
That worked a treat, thanks a lot.
24-05-2002 at 07:59 AM
|
ASHISH25 Level: Guest
Re: Access97 Variables in place of fields Archived to Disk
using variable use fieldname
Dim dbs As DATABASE, rst As Recordset, strSQL As String, strFieldName as string, strWhatever as string
Set dbs = CurrentDb
strSQL = "SELECT * FROM ATABLE"
Set rst = dbs.OpenRecordset(strSQL)