More Message Box Help

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
 
B

BruceM

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.
 
M

Mr-Re Man

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.
 
B

BruceM

Sorry, forgot the parentheses:

If MsgBox (strMsg, vbOKCancel, strTitle) = vbOK Then
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top