How to query the controls in form using vb

A

Andy Chan

I have a group of checkboxes ( about 20 ) which i created
during runtime.

I want to check the status of each checkbox in the form to
see if the value is true or false.

how do i do it ?

Thanks
Andy
 
R

Robin Hammond

Andy,

try this. It's set up to run from a form control, with all check boxes names
as "chk...."

Option Compare Text
Private Sub CommandButton1_Click()
Dim ctlTest As msforms.Control
For Each ctlTest In Me.Controls
If Left(ctlTest.Name, 3) = "chk" Then Debug.Print ctlTest.Name,
ctlTest.Value
Next ctlTest
End Sub

HTH,

Robin Hammond
www.enhanceddatasystems.com
 
Top