checkbox name

T

Terry

Hello
I have a series of 65 checkboxes.
Im trying to build a sub that will cycle through all the checkboxes on my
form that begin with "chk".
Ex: If the names of some checkboxes were chk_A,chk_B,chk_C, how can I have a
for loop to look at all checkboxes on my form and apply a .enabled=false to
all that begin with chk?
Kinda like this idea (but it does not work as most of you would summize).
The checkboxes Im using are from the toolbox bar.

Sub disablechecks()
Dim chk as control
For each chk in me.controls
If chk.controltype=acCheckbox then
If controls(chk).name like "chk" then
controls(chk).enabled=false
End if
End if
Next
End Sub

Thank you so much
Terry V
 
N

Nikos Yannacopoulos

Terry,

Try this:

Sub disablechecks()
Dim chk as control
For each chk in me.controls
'If chk.controltype=acCheckbox then 'do you need this? Other control
types starting chk?
If left(chk.name,3) = "chk" then chk.enabled=false
'End if
Next
End Sub

HTH,
Nikos
 
T

Terry

Thank you, this works just the way I need it too :)
There does not seem to be too much help in Access help on checkboxes..

Terry
 

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