Working with Fields in Recordsets

harrisw

Registered User.
Local time
Today, 22:44
Joined
Mar 27, 2001
Messages
131
How do I access the data that is held within a recordset so that I can use it in various ...if... statemnents in an access database.?
 
You have to open up the database and then open up your recordset in your code....


'Declare Your Variables...
Dim MyDB as database
Dim MyRecs as Recordset

'Set Your Variables....
Set MyDB = currentdb
set MyRecs = MyDB.openrecordset("RecordSetName")

'Now all you have to do to refer to a field is use...

MyRecs![FieldName]

At the end of your functions, make sure you clean up your objects to clear up memory...

MyDB.close
Set MyRecs = Nothing
Set MyDB = Nothing

Hope this helps you...

Doug
 
Great that works.

Next How do I find a specific record and display only the fields that belong to it?
 
I'm trying specifically to do the following

Myrecordset.FindFirst "[User ID] =" & CurrentUser()

it blows up with an error.

Any ideas?
 
Sure, you need tick marks(') around string variables... Try this...

Myrecordset.FindFirst "[User ID] ='" & CurrentUser() & "'"

That should work for you.

Doug
 

Users who are viewing this thread

Back
Top Bottom