Full Version: Is their a quicker way?
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
GTurner
Hi,

On my form, I've got many check-boxes. I want to set up a reset button, and I usually list all commands within VBA individually to reset their values .
i.e.
check0 = 0
check1 = 0
check2 = 0
and so on.

My question is : - is this the best way to reset, or is their a much more abbreviated way to reset the values of all check boxes on my form?

Thanks
bikam0wz
CODE
Private Sub ResetCheckBoxes()
On Error GoTo ErrHandler

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

ExitHere:
   On Error Resume Next
   Exit Sub
ErrHandler:
   MsgBox ("Error No: " & Err.Number & vbCrLf & vbCrLf & Err.Description)
   Resume ExitHere
End Sub
GTurner
Thankyou for the code sample.
Put that it in their, naturally works fine!
Appreciate your response. I take it where you have ACCheckbox, I would amend accordingly if I was looking to reset values of option buttons or other control types.?

Thanks again
bikam0wz
No worries. Check out 'ControlType' in the vb help file for a list of constants.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.