P
philhood2
Hi,
Thanks for the advice. Having read your reply, I don't
think I explained the situation very well!
I have a form on which there are several similar controls
named 2000, 2001, 2002, 2003, 2004 (they are all check
boxes representing years)
I am trying to write an event procedure for the form that
applies a test to each of the controls in turn. This is
why I want to refer to the control using a variable so
that I can increment the variable at the end of the test
in order to check the next control.
It would look something like:
aVariable = 2000
Do until aVariable = 2004
if Forms!Years!aVariable = x then do something
aVariable = aVariable + 1
Loop
Does this make sense? Is there a way of doing this?
Thanks again.
Phil.
Thanks for the advice. Having read your reply, I don't
think I explained the situation very well!
I have a form on which there are several similar controls
named 2000, 2001, 2002, 2003, 2004 (they are all check
boxes representing years)
I am trying to write an event procedure for the form that
applies a test to each of the controls in turn. This is
why I want to refer to the control using a variable so
that I can increment the variable at the end of the test
in order to check the next control.
It would look something like:
aVariable = 2000
Do until aVariable = 2004
if Forms!Years!aVariable = x then do something
aVariable = aVariable + 1
Loop
Does this make sense? Is there a way of doing this?
Thanks again.
Phil.
..-----Original Message-----
Phil,
You can create a reference to a control in a form's module
as follows:
Dim ctl As Control
Set ctl = Me!MyControl 'where MyControl is the control name
To change the value contained in the control:
Me!ctl = 2000
.