I'm trying to assign the name of a field in a loop to a specific variable in access vba. Then I need this variable to read a specific record from the database. Below you have the piece of code:
For n = 0 To numfields - 1
a = "!" & rst.Fields(n).Name
If IsNull(!Field1) = False Then
If n = 1 Then strOutput = strOutput & a
If n <> 1 And n <> 0 Then strOutput = strOutput & ";" & "!Field" & n
End If
Next n
The problem is the following: the stored value in the variable would be "!Field(n)" in text and will not get the value from the database in my conditional statement since it's not reading it. Is there any way to convert this text to and actual !Field(n) variable that can read from the database?
Thank you for your help.
ato store the name ofFields(n)or the value which is present inFields(n)?a = rst.Fields(n).Value