borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Standard EXE)Next Topic (Retrieving fieldnames) New Topic New Poll Post Reply
AndreaVB Forum : Database : Access97 Variables in place of fields
Poster Message
dbased
Level: Guest


icon 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
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Access97 Variables in place of fields  Archived to Disk

Try:

rst.Fields(strFieldname)

23-05-2002 at 08:34 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
dbased
Level: Guest

icon Re: Access97 Variables in place of fields  Archived to Disk

That worked a treat, thanks a lot.

24-05-2002 at 07:59 AM
| Quote Reply
ASHISH25
Level: Guest

icon 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)

strWhatever = rst!name

09-08-2002 at 10:39 AM
| Quote Reply
AndreaVB Forum : Database : Access97 Variables in place of fields
Previous Topic (Standard EXE)Next Topic (Retrieving fieldnames) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder