checkbox name

  • Thread starter Thread starter Terry
  • Start date Start date
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
 
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
 
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
 
Back
Top