yes/no message box

J

Jason

I am having problems getting my yes/no message box to work:
I want a box to come up and if they press yes, it prints
the report, and if no, it cancels.

I am using this code:

Function MessageBox(Optional MsgBox)
Dim Response As Integer
Response = MsgBox("Are you sure you want to print the
report?", (36), "Print Confirm")
If Response = vbYes Then
DoCmd.OpenReport "Walklist Parameter", acViewNormal
Else
Exit Function
End If
End Function

But it keeps saying type mistmatch and is highliting the
response= line.
What am I doing wrong?
 
J

Jason

.....I had to take the Optional MsgBox out of the first
line:

Function MessageBox()
Dim Response As Integer
Response = MsgBox("Are you sure you want to print the
report?", (36), "Print Confirm")
If Response = vbYes Then
DoCmd.OpenReport "Walklist Parameter", acViewNormal
Else
Exit Function
End If
End Function

This now works fine except that when you press yes, it
goes to a parameter query that the report is based on. If
they press cancel in that box, it comes up with the
error, "The OpenReport action was cancelled."
Can I prevent this from appearing?

-andy
 

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