More Message Box Help

  • Thread starter Thread starter Mr-Re Man
  • Start date Start date
M

Mr-Re Man

I would really appreciate some code that would prompt a use to pick yes or no
before unchecking a tick box.

For example

If I have a check box called "Excluded_yn" and four other boxes called
"Reason_cbo", "WhoExcluded_txt", "StartDate_date" and "EndDate_date"

If the checkbox is ticked and all the fields are populated but then a user
wishes to uncheck the check box. I want the boxes to be clear, but need to
make sure the user understands that by de-selecting the check box, they'll be
aware that the information will be lost.

regards
 
In the Before Update event of the check box:

Dim strMsg as String, strTitle as String

strMsg = "This will delete other fields"
strTitle = "Delete Advisory"

If Me.Excluded_yn = False Then
If MsgBox strMsg, vbOKCancel, strTitle = vbOK Then
Me.Reason_cbo = Null
Me.WhoExcluded_txt = Null
Me.StartDate_date = Null
Me.EndDate_date = Null
Else
Cancel = True
End If
End If

Add as much information as needed to strMsg, and change strTitle as you
prefer.
 
Thanks Bruce, I'm getting an error on the following line

If MsgBox strMsg, vbOKCancel, strTitle = vbOK Then

It's indicating that a compile error or syntax error is present.
 
Back
Top