Identiying whether the user is checking or unchecking a checkbox

w11184

Registered User.
Local time
Today, 00:34
Joined
Feb 20, 2012
Messages
41
I have a checkbox on my form that basically deletes a record when the user ticks the checkbox. What I want to know is how do i check whether the person is "ticking" or "unticking" a checkbox before any action is carried out?
 
Use the AfterUpdate event of the Check box.
Code:
Private Sub checkBoxName_AfterUpdate()
    If Me.checkBoxName Then
        MsgBox "CheckBox is now Ticked"
    Else
        MsgBox "CheckBox is now Unticked"
    End If
End Sub
 
but what about if I want to confirm with the user whether they defintiely want to tick/untick it?
 
Use the BeforeUpdate event instead of AfterUpdate.
Code:
Private Sub checkBoxName_BeforeUpdate(Cancel As Integer)
    If MsgBox("Are you sure you want to " & IIF(Me.checkBoxName = True, "Tick", "Untick") & " the checkbox?", vbYesNo) = vbNo Then
        Cancel = True
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom