Variable as a name of the recordset's field (1 Viewer)

polina

Registered User.
Local time
Today, 15:07
Joined
Aug 21, 2002
Messages
100
Hi,
I have a function that accepts the field name as a parameter

Sub MyFunction(ByVal strName)

In the function I set the DAO recordset:

Set rst = CurrentDb.OpenRecordset("MeterVolumes")

Then I want to use the parameter strName as the field name of that recordset

.AddNew
rst!strName = whatever
.Update

the syntax is not correct. I tried rst! & strName, it didn't work as well. Is there a way to use a variable a recordset's field name

Please advise

THanks a lot
 

Mile-O

Back once again...
Local time
Today, 15:07
Joined
Dec 10, 2002
Messages
11,316
rst.Fields(strFieldName) = 'whatever'
 

Users who are viewing this thread

Top Bottom