Hi,
Having a little trouble trying to use a variable to specify a form control.
In a form I have 40 text fields which are named num1, num2,...num40.
In my code I have a dlookup command that then looks for the occurence of the number 1 within a table and updates num1 with the count. I want to repeat this for the forty text fields ( i.e. number 2 for num2,... number 40 for num40. I am trying not to write the dlookup command 40 times. What I have tried (and failed) is
Dim fieldname as control
Dim i as integer
For i = 1 to 40
set fieldname="num" & i (requires object error)
Me.[Fieldname]= Dlookup(field, table, criteria = i)
next i
If I don't use set I error out on me.fieldname as can't find field field name.
Is this possible?
Regards
GDLKM
This
Having a little trouble trying to use a variable to specify a form control.
In a form I have 40 text fields which are named num1, num2,...num40.
In my code I have a dlookup command that then looks for the occurence of the number 1 within a table and updates num1 with the count. I want to repeat this for the forty text fields ( i.e. number 2 for num2,... number 40 for num40. I am trying not to write the dlookup command 40 times. What I have tried (and failed) is
Dim fieldname as control
Dim i as integer
For i = 1 to 40
set fieldname="num" & i (requires object error)
Me.[Fieldname]= Dlookup(field, table, criteria = i)
next i
If I don't use set I error out on me.fieldname as can't find field field name.
Is this possible?
Regards
GDLKM
This