Stop print more than one copy of a report

  • Thread starter macneil via AccessMonster.com
  • Start date
M

macneil via AccessMonster.com

I am trying to print only the current record with the following code and I
get 2 copy of the same report everytime I print and I also get an error
message.

Private Sub Command59_Click()
On Error GoTo Err_Command59_Click

Dim stDocName As String

stDocName = "rptDocSub"
DoCmd.OpenReport stDocName, acNormal

DoCmd.OpenReport "rptDocSub", acNormal
Reports![rptDocSub].Filter = "Primary ID = " & Me![Primary ID]
Reports![rptDocSub].FilterOn = True
DoCmd.PrintOut acSelection

Exit_Command59_Click:
Exit Sub

Err_Command59_Click:
MsgBox Err.Description
Resume Exit_Command59_Click

End Sub

After I click the button the code runs and prints the 2 copies and then I get
this message

'The report name 'rptDocSub' you entered is misspelled or refers to a report
that isn't open or doesn't exist'

Can someone show me what I am doing wrong?
 
M

macneil via AccessMonster.com

I figured out why I got 2 copies. Still need help with the error message.
I am trying to print only the current record with the following code and I
get 2 copy of the same report everytime I print and I also get an error
message.

Private Sub Command59_Click()
On Error GoTo Err_Command59_Click

Dim stDocName As String

stDocName = "rptDocSub"
DoCmd.OpenReport stDocName, acNormal (NEEDED TO DELETE THIS LINE OF CODE)

DoCmd.OpenReport "rptDocSub", acNormal
Reports![rptDocSub].Filter = "Primary ID = " & Me![Primary ID]
Reports![rptDocSub].FilterOn = True
DoCmd.PrintOut acSelection

Exit_Command59_Click:
Exit Sub

Err_Command59_Click:
MsgBox Err.Description
Resume Exit_Command59_Click

End Sub

After I click the button the code runs and prints the 2 copies and then I get
this message

'The report name 'rptDocSub' you entered is misspelled or refers to a report
that isn't open or doesn't exist'

Can someone show me what I am doing wrong?
 

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