Printing Report after Question

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
 
C

Cheryl Fischer

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,
 

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