Reset check boxes

SheaLee

Registered User.
Local time
Today, 10:08
Joined
Dec 22, 2005
Messages
40
I have a form with several records, the user is given the option to check a box if he want to send a email, what I need to happen when the form loses focus or is closed, how do I re-set all check boxes = -1 back to 0??
Thanks in advance.
 
Code:
    Dim ctrl As Control
    For Each ctrl In Me.Controls
        If ctrl.ControlType = acCheckBox Then
            ctrl.Value = False
        End If
    Next
 
Or run an update query and call it from a Docmd.
 
Hmmmm still I'm doing something wrong

Private Sub ResetChkBoxes()
Dim ctrl As Control

For Each ctrl In Me.chkSendEmail 'Me.Controls
If ctrl.ControlType = acCheckBox Then
ctrl.Value = False
End If
Next

End Sub
I'm getting the following error "Expected End Sub"
 
As I said - an Update query is far easier. Just set the value to 0. You call the Update query with simple Docmd statement.
 
you've got it except that the .Controls refers to the .Controls collection of the form...and you forgot to tell the system what you wanted to increment to next

SheaLee said:
Private Sub ResetChkBoxes()
Dim ctrl As Control

For Each ctrl In Me.Controls
If ctrl.ControlType = acCheckBox Then
ctrl.Value = False
End If
Next ctrl

End Sub
 
Last edited:
now I'm getting the following error
Run-time error 2448
You can't assign a value to the object

I placed the above code in the Form Close
 
sorry...missed that. Remove the .value statement

Code:
Dim ctrl As Control

For Each ctrl In Me.Controls
    If ctrl.ControlType = acCheckBox Then
       ctrl = False
    End If
Next ctrl
 
Bodisathva said:
sorry...missed that. Remove the .value statement
Strange... worked for me the way it was :confused:
Maybe it's acting differently because it was in the Close event (I just tested it as a Button.OnClick) or different version of Access (I'm using 2003)
 

Users who are viewing this thread

Back
Top Bottom