Variable as a name of the recordset's field

polina

Registered User.
Local time
Today, 20:54
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
 
rst.Fields(strFieldName) = 'whatever'
 

Users who are viewing this thread

Back
Top Bottom