Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax for Variable Field Names

Status
Not open for further replies.

ottman2

Programmer
Jun 26, 2001
20
0
0
US
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
 
Why not simply use an array ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That will work.
Thanks.

Dim glbLastExportDateNP(2) as date
...
glbLastExportDateNP(x)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top