Newbie: How to refer to field in a loop

M

MAC

I don't think I fully understand what it is you are trying
to do.
However, with regard to your first question.
I would use a variable to contain the Field Name as
follows:

Dim stFieldName as string
....
For I=1 to 5
stFieldName="ID_"& I
....
Next

Perhaps, you could use this variable in a parameter query.

MAC
-----Original Message-----
In a loop how can you refer to a field that have a number at the end:
ID_1, ID_2 up to 5?
For i=1 to 5
* run a query that is base on each field query_1, query_2 etc...
next
And for futur reference, is it possible to reference
inside a query the value of the i in the loop?
so would end up like:
stDocName = "Kit_UPD"
for i =1 to 5
DoCmd.OpenQuery stDocName, acNormal, acEdit
** in the query the value of i is used to reference the field
Next
I'm getting errors on getting the value of the "i" when I
try to add it to the name of the field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top