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!

How to Stop Access 97 From Printing Form With Reports 2

Status
Not open for further replies.

LittleC

Programmer
Dec 19, 2003
13
US
Hi!

Hope someone may help me out with this one:

THE GOAL: I'm trying to improve the design of a form by removing the buttons used to print reports to a subform that pops up like a dialog box. This custom-made dialog box has one button for each report a user needs to print (nine reports in all).

THE OBSTACLE: When i use an on-click event to run the code to print reports from this subform, the subform itself prints out with the reports (which wastes toner). This problem does not occur when i use an on-click event to run the same code from the main form.

Here is the VBA code i'm using to open the subform:

'=============================
Private Sub Command178_Click()
On Error GoTo Err_Command178_Click

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "frmIssues_501"
strLinkCriteria = "[SSN]=" & "'" & Me![SSN] & "'"
DoCmd.OpenForm strDocName, , , strLinkCriteria

Exit_Command178_Click:
Exit Sub

Err_Command178_Click:
MsgBox Err.Description
Resume Exit_Command178_Click

End Sub
'============================

Here is the VBA code i'm using to print out the reports:

'============================
Private Sub Command17_Click()

Dim strDocName As String
Dim strFilter As String

strDocName = "Cover"
strFilter = "SSN = Forms!frmIssues!SSN and IssueNumber = Forms!frmIssues!IssueNumber"
DoCmd.OpenReport strDocName, acPreview, , strFilter
DoCmd.PrintOut acPrintAll, , , acHigh, 2, 1

strDocName = "LTR-ERI-ATPNAS"
strFilter = "SSN = Forms!frmIssues!SSN and IssueNumber = Forms!frmIssues!IssueNumber"
DoCmd.OpenReport strDocName, acPreview, , strFilter
DoCmd.PrintOut acPrintAll, , , acHigh, 2, 1
DoCmd.Close acDefault, , acSavePrompt

End Sub
'=============================

We're using Access 97 (i know--it's a dinosaur, but it is all we have to work with). Any suggestions as to how to stop the subform from printing with the reports will be appreciated!

Thanks in advance!

Christopher in Indiana
 
Hi!

In your Command17_Click event, you use the printout command, which will print the current object (the form).

Rather, if possible, use the acNormal to print directly, in stead of acPreview:

[tt]docmd.openreport strDocName,acNormal,,strFilter[/tt]

In my version (xp), I'm allowed to use the docmd.printout method in the On Activate event of the report, so you could try that too (continue to use acPreview), to get high quality and 2 copies.

Access 97 is still a good tool!

HTH Roy-Vidar
 
I think there is some confusion since a subform generally is used to describe a form embedded on a form. A form that opens by itself is generally called just a form or dialog form. You could try make the pop-up form invisible prior to doing the printing.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
RoyVidar:

Yep, acNormal works much better. Thanks!

===============================================

dhookom:

Right; i should have referred to it as a popup form that is linked to the main form. My goal was to create something like a custom-made dialog box.

Thanks for your suggestion! I'll let you know if setting the visible property to false works.
 
Thank you dhookom! Adding the
Code:
 Me.Visible = false
line of code, which i inserted at the beginning, solved the problem.

You sure do deserve a star!

Thank you! Thank you!

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top