Printing Report after Question

  • Thread starter Thread starter Harmony
  • Start date Start date
H

Harmony

I want the user to push a button and it prompt ask them if
they want to print a report. If they click yes, I want the
report to print, but I cannot get it to work. My report
name is R_ALetter. Below is my code, what did I do wrong?



Private Sub Command22_Click()
Dim Reponse
Dim MyString

Response = MsgBox("Do you want to print the Welcome
Letter?", vbYesNo, "Question")
If Response = vbYes Then
MyString = ObjAccess.DoCmd.OpenReport("R_ALetters",
acViewReport)

Else: MyString = "No"

End If


End Sub
 
How about ...

Private Sub Command22_Click()
Dim Reponse as Integer

Response = MsgBox("Do you want to print the Welcome Letter?", vbYesNo,
"Question")
If Response = vbYes Then
DoCmd.OpenReport "R_ALetters", acViewPreview
else
'perform some other process - or do not use an else
End If

You attempted to use acViewReport for the view argument but I'm not aware
that it is one of the available constants for report opening. acViewNormal,
which is the default prints the report immediately, while acViewPreview
displays the report to the screen.

hth,
 
Back
Top