Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Stop Access From Printing Subform When Reports Print Out

Status
Not open for further replies.

LittleC

Programmer
Dec 19, 2003
13
US
Hi!

I've gotten some helpful advice from the experts @ Tek-Tips in the past & thought i'd ask for assistance on this one.

When i attempt to use an on click event to print reports, the subform also prints. Is there a fix for this bug in Access 97 or is there something wrong with my code?

Here is the code i'm using to open a subform from which the user may select reports to be printed:

Code:
'===========================================

Private Sub Command1_Click()

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "Customer Subform"
strLinkCriteria = "[ID]=" & "'" & Me![ID] & "'"
DoCmd.OpenForm strDocName, , , strLinkCriteria

End Sub

'=====================================

Here is the code i'm using to print out one of the reports from the subform:

Code:
'=====================================

Private Sub Command2_Click()
    
Dim strDocName As String
Dim strFilter As String

strDocName = "CoverLetter"
strFilter = "ID = Forms!frmIssues!ID and OrderNumber = Forms!frmIssues!OrderNumber"
DoCmd.OpenReport strDocName, acNormal, , strFilter
DoCmd.PrintOut acPrintAll, , , acHigh, 2, 1
       
strDocName = "OrderForm"
strFilter = "ID = Forms!frmIssues!ID and OrderNumber = Forms!frmIssues!OrderNumber"
DoCmd.OpenReport strDocName, acNormal, , strFilter
DoCmd.PrintOut acPrintAll, , , acHigh, 2, 1
DoCmd.Close acDefault, , acSavePrompt
        
End Sub

'==========================================

When a user clicks on the button on the subform, the CoverLetter and OrderForm reports print out OK, but the Customer Subform also prints more than once. However, when the same on click event is used to run the same code from the Customers main form, the Customers form does not print out with the two reports. It's only a problem with the subform, which is something like a dialog box with the popup property set to yes.

I'm pulling what little hair i have left out over this one. Is there anyone who might be able to save me from going bald? ;-)

Any suggestions will be appreciated.
 
I swear we already answered this question. You open the report in acNormal, which will already send the report immediately to the printer. Then you remove the "DoCmd.PrintOut" line. Problem solved.


I swear I saw this a few days ago.


Dude, do you ever read your own threads after you post them? Check your member profile, and then click on "Threads I've Started". This is ridiculous.

 
Thank you, foolio.

Again, i apologize for posting in different forums; i thought i would get a range of opinions by asking a range of experts.

In the future i'll post questions in just one forum.
 
I tried foolio's suggestion & i'm not sure why it did not solve the problem.

For anyone who runs in to the same trouble, here is a fix that did work:

Code:
Private Command1_Click()
    
Me.Refresh
Me.Visible = False

Dim strDocName As String
Dim strFilter As String
   
strDocName = "CoverLetter"
strFilter = "ID = Forms!frmIssues!ID and OrderNumber = Forms!frmIssues!OrderNumber"
DoCmd.OpenReport strDocName, acPreview, , strFilter
DoCmd.PrintOut acPrintAll, , , acHigh, 2, 1
DoCmd.Close acDefault, , acSavePrompt
    
strDocName = "OrderForm"
strFilter = "ID = Forms!frmIssues!ID and OrderNumber = Forms!frmIssues!OrderNumber"
DoCmd.OpenReport strDocName, acPreview, , strFilter
DoCmd.PrintOut acPrintAll, , , acHigh, 2, 1
DoCmd.Close acDefault, , acSavePrompt
        
End Sub

The
Code:
 Me.Visible = false
code kept the popup form from being visible so it would not print with the reports. The
Code:
 DoCmd.Close acDefault ,, acSavePrompt
closed the print preview after two copies of each report printed.

Thanks to the one who suggested setting the visible property to false!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top