• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 528
  • Last Modified:

Print in landscape, form, report

Experts,

I have this form.
I have a button on it to print.
I think it is best to print a report instead of the form.

on the button of my form I have this:

Private Sub cmdPrintTheRpt_Click()

    DoCmd.OpenReport "rptStatus_TenderPerDeal", acViewNormal, "", "[ID]=[Forms]![frmStatus_TenderPerDeal]![ID]", acNormal

End Sub

Open in new window


I basically am opening the report with the same ID as the the ID on the form.  Both report and form have the same recordsource (I saved the form as a report).  

When I press the button on the form, the code above returns a runtime error 2212:  "Cant print the report."...see pic below.  I got the code from online and I am not even sure why the code executes a PRINT because I dont see any code for PRINT (only OPEN).

How can I print the report but with the Where condition?  Any better ideas are welcome.  thank you.
untitled.JPG
0
pdvsa
Asked:
pdvsa
  • 3
  • 3
  • 2
2 Solutions
 
IrogSintaCommented:
Try this:
DoCmd.OpenReport "rptStatus_TenderPerDeal", acViewNormal, "", "[ID]=" & Me.[ID], acNormal

Open in new window


The above would work if ID is a Number data type.  If it is Text, you would need this instead:
DoCmd.OpenReport "rptStatus_TenderPerDeal", acViewNormal, "", "[ID]='" & Me.[ID] & "'", acNormal

Open in new window

0
 
pdvsaAuthor Commented:
Hi Irogsinta,

I see I had a misplaced quote...I still have that error though.  The fields are number fyi...

any other ideas?   thank you.
0
 
IrogSintaCommented:
Do you still get the same error if you just try printing without a criteria?
DoCmd.OpenReport "rptStatus_TenderPerDeal"
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
pdvsaAuthor Commented:
Yes, I do  

but I dont have any errors if I add  acViewPreview :

DoCmd.OpenReport "rptStatus_TenderPerDeal", acViewPreview

What do you think now?  thank you
0
 
Rey Obrero (Capricorn1)Commented:
do you have any default printer setup for the report?
0
 
pdvsaAuthor Commented:
There is a default printer but it is the network printer and I am not connected....printer is at work.
0
 
IrogSintaCommented:
There's your problem.  Change it to use your default printer and not a specific printer.
0
 
Rey Obrero (Capricorn1)Commented:
< the network printer and I am not connected...>

that is the reason why you are getting the error
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now