anyone know Access VBA?

Permabanned
Joined
24 Dec 2002
Posts
474
Location
Chelmsford, Essex. Bling Bling
Ive got a few checkboxes on an Access form and i want to loop through them checking to see if theyre ticked or not, im doing this at the moment....


Code:
    Dim chkObj as Checkbox
    
    
    For Each chkObj In Me.Controls
        If chkObj = False Then
            Select Case chkObj.Name
.
.
.
.
            End Select
        End If
    Next

Now it goes into the for..each loop once then when it hits the Next i get a type mismatch error. Any ideas?
 
I don't know VB but I would guess that you have more than just check boxes in the collection Me.Controls. perhaps you need to check it's type first? Also I would have thought that your for each loop needs some sort of end marker?

HT
 
thanks for that peeps, ill give it a bash tomorrow. I didnt think i had to check for the object type since id already defined it as a checkbox, so i was hoping it would essentially be "for each checkbox on the form do this"

Anyway, ta for the help, fingers crossed thatll work.
 
Ah yeah i think my original post is wrong.

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If ctl = False Then
Select Case ctl.Name

End Select
End If
End If
Next
 
Back
Top Bottom