• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 532
  • 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
 
pdvsaProject financeAuthor 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
pdvsaProject financeAuthor 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
 
pdvsaProject financeAuthor 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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