Proper procedure needed to reset checkbox to True after Msgbox returns VBNo

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Need the correct procedure for the following:
1. A record's checkbox value = True
2. User clicks checkbox to uncheck and gets a msgbox that
asks.. Are you sure?
3. IF msgbox = vbno Then
4. Return value of checkbox to checked (True)
5. Else value of checkbox = False

Hope this is enough info.
Thanks in advance
 
You could use the check box's AfterUpdate event to undo it if the user backs
out:

Private Sub chk_AfterUpdate()
If MsgBox("Confirm change", vbYesNo+vbDefaultButton2) <> vbYes Then
Me.chk.Undo
End If
End Sub
 
Allen,
Thanks for the suggestion, but it didn't seem to work for
me.
Just to make sure, I created a new form with a checkbox
control and added the sub you provided to the AfterUpdate
event.
When I click the checkbox the msgbox executes like it
should, but when I click "No" the checkbox checks (or
unchecks) anyway.
Am I missing the obvious or what?

Thanks in advance.
 
The line:
Me.[WhateverYourCheckboxIsCalled].Undo
should return the check box to the state that it was before you started
editing/creating this record.

If you wanted to set it to No, you could use:
Me.[WhateverYourCheckboxIsCalled] = False
 
Back
Top