I want to reduce duplicating code, by looping through the field names. Is there syntax to reference variables i.e. glbLastExportDateNP1, replacing the 1 with the x?
Here is a simple version of what I'm trying to do.
For x = 1 To 2
Set inputdb = CurrentDb.OpenRecordset("qry_NP" & x & "Max")
inputdb.MoveFirst
If x = 1 Then
glbLastExportDateNP1 = inputdb!Maxofexportdate
Else
glbLastExportDateNP2 = inputdb!Maxofexportdate
End If
Next
Here is a simple version of what I'm trying to do.
For x = 1 To 2
Set inputdb = CurrentDb.OpenRecordset("qry_NP" & x & "Max")
inputdb.MoveFirst
If x = 1 Then
glbLastExportDateNP1 = inputdb!Maxofexportdate
Else
glbLastExportDateNP2 = inputdb!Maxofexportdate
End If
Next