Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a message box to my command button

Status
Not open for further replies.

CoolFactor

Technical User
Dec 14, 2006
110
0
0
US
This maybe very simple but how can I add a message box to the following command button on the click event in which if the answer to the question is Yes then open the Report and if the answer to the question is No then do not open the Report. I guess it's more like a statement followed by a question:

"In order view this Report you must first Update Price Points. Have Price Points been Updated?"

The following code is where I want to include my message:
Private Sub cmdP3MSummary_Click()
DoCmd.OpenReport "P3M_Summary", acViewPreview, "", ""
DoCmd.Maximize
End Sub
 
Try this in your OnClick event

Code:
intResponse = MsgBox("Do you wish to print the report", vbYesNo, "Your Database Name")
    
    If intResponse = vbYes Then
        DoCmd.OpenReport "P3M_Summary",acViewPreview, "", ""
        DoCmd.Maximize
        Else
    End If

Hope this helps you out
 
or better than that :

Code:
intResponse = MsgBox("In order view this Report you must first Update Price Points." & Chr$(13) & _
    "Have Price Points been Updated?", vbYesNo, "Your Database Name")
    
    If intResponse = vbYes Then
        DoCmd.OpenReport "P3M_Summary",acViewPreview, "", ""
        DoCmd.Maximize
        Else
             're open the form to update price points
    End If
 
How are ya CoolFactor . . .

Adding some formatting to the code gives:
Code:
[blue]   Dim Msg As String, Style As Integer, Title As String, DL As String
   
   DL = vbNewLine & vbNewLine
   
   Msg = "In order view this Report you must first Update Price Points!" & DL & _
         "Have Price Points been Updated?"
   Style = vbQuestion + vbYesNo
   Title = "Response Required! . . ."
   
   If MsgBox(Msg, Style, Title) = vbYes Then
      DoCmd.OpenReport "P3M_Summary", acViewPreview
      DoCmd.Maximize
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top