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!

Printing popup not report 1

Status
Not open for further replies.

janetlyn

Technical User
Jan 29, 2003
516
US
I have a form "Reports" with thirty labels, each label contains a report. When one of the labels is selected it opens a popup "PUReports" and then the specific report. On the popup are two buttons. Print or Close. If they select print, it should print the report, close the report, close the popup and return to the "Reports" form. If they select close, it closes the popup and the report.

My problem is that when they select print, it is either (depending on my code) printing the popup itself, or the "Reports" form (like I did a print screen). I cannot get it to print the actual report that is opened. I have not yet, but in the end would like to take away all toolbars, buttons, etc. so only the report and popup is showing so they have to answer the popup only.

Here is the code I have so far:

Private Sub Label1_Click()

REM Close the popup
DoCmd.Close

REM Open Module that prints report
Call PrintReports

REM Open Module closing all reports
Call CloseOpenReports

REM Return to Reports Form
DoCmd.OpenForm "ReportsMenu", acNormal

REM Maximize reports form
DoCmd.Maximize

End Sub

MODULE (this module is the same as close reports except for the DoCmd line)

Sub PrintReports()
Dim rpt As Report
' Enumerate Open Reports in collection.
For Each rpt In Reports
DoCmd.PrintOut (acPrintAll)
Next rpt
End Sub

Any help or suggestions would be greatly appreciated.
Janet Lyn
 
First... a little remark, when you use docmd.close, you should ALWAYS put the parameters... that could give you some problems :

docmd.close acform, "FormName"

Second... to print a report, you should use the following command :

docmd.OpenReport "ReportName", acViewNormal

the acViewNormal parameter will send it directly to the default printer.

Deulyd
 
The first one (DoCmd.Close) I can fix. The second causes two problems.

1) To do it your way I would have to create one Pop-UP per report, that's 42 popups.

2) I don't want it to go directly to the printer. That is the whole purpose of the popup. They can either preview then close (Label 2) or Print the report (Label 1).

Maybe I'm being obtuse and just do not understand what you are getting at. Try again? Thanks

Janet Lyn
 
Ok... now I think I understand. Here's the code you need for your pop-up:

---------------------------------------------------
' CLOSE BUTTON
Private Sub cmdClose_Click()
' Close the report
DoCmd.Close acReport, "REPORT NAME" ' closes the report

' Close the form
DoCmd.Close acForm, Me.NAME ' closes the pop-up
End Sub

' PRINT BUTTON
Private Sub Command2_Click()
' Print the report
DoCmd.OpenReport "Reporttest", acViewNormal

' Close the report
DoCmd.Close acReport, "REPORT NAME" ' closes the report
End Sub
-------------------------------------------------------

Is that what you are looking for?
 
My close button works fine. Actually it is a module. The problem with the PRINT BUTTON above is that I have to put in a report name. Again that would cause me to have to write 42 popups. Maybe I need to go about this a different way. Any suggestions? JL
 
So if you can capture the name of the active (sub)report into a variable you can then pass it along to PrintReports?
 
Yes. I hope you are asking me and not telling me. Because I do not know how to do what you suggest but it sounds like it would work. Help? Thanks, Janet Lyn
 
Yes I was asking you, I do not know how to do that off the top of my head, but now that we have the question isolated, perhaps deulyd can provide some assistance :)
 
Yep, thanks for helping me get to the point. JL
 
That should print all the reports in your collection if that's what you want...

Sub PrintReports()
Dim rpt As Report
' Enumerate Open Reports in collection.
For Each rpt In Reports
docmd.openreport rpt.name, acViewNormal
Next rpt
End Sub

--------------------------------

If you want to print a single report; call the procedure using a parameter :

Sub PrintReports(strRptName as string)
docmd.openreport strRptName, acViewNormal
End Sub


 
Deulyd, thank you for the code. It actually makes since to me. Have a wonderful day. JL
 
Deulyd, since you marked this thread I would like see if you could continue helping with this problem please. I tried to find another thread where there was a report issue and someone had me do a public module and cannot find it. Here is my code:

MODULE:
Sub PrintReports()
Dim RPT As Report
' Enumerate Open Reports in collection.
For Each RPT In Reports
DoCmd.PrintOut
Next RPT
End Sub

LABEL to print from popup:
Private Sub Label1_Click()
DoCmd.Close
Call PrintReports
Call CloseOpenReports
DoCmd.OpenForm "FRM-MaintScreen", acNormal
DoCmd.Maximize
End Sub

LABELs asking to preview report from form:
Private Sub Label4_Click()
DoCmd.OpenForm "FRM-PopupMaint", acNormal
DoCmd.OpenReport "RPT-ProjectNotinTBL-Brochures", acViewPreview
DoCmd.Close acForm, "FRM-MaintScreen"
End Sub

Private Sub Label7_Click()
DoCmd.OpenForm "FRM-PopupMaint", acNormal
DoCmd.OpenReport "RPT-ProjectNotInTBL-ConstCost", acViewPreview
DoCmd.Close acForm, "FRM-MaintScreen"
End Sub

Yesterday, I opened my form, selected Label 4, it opened a report and the popup. I selected Label1 to print the report. It printed the report fine. I then selected Label 7, it opened the popup and report, I selected it to print and it printed the my form behind the report.

How can I stop this please? JL
 
Deulyd, I am still having this same problem and cannot figure out the answer. Can you help please? Thanks, JL
 
Hi Janetlyn, I've been really busy lately... Sorry for the late answer. But I have difficulty to understand what you want to do, send me your code so I can understand better at danielbordeleau@hotmail.com

Deulyd
 
Daniel, I am just glad you answered. Thank you for your help. I zipped and then sent the email. It is 7,000K. I appreciate the help and please don't feel like you have to kill yourself to hurry and help me. I have put up with this problem since last July, I'm sure I can stand to wait longer. I am just so happy to finally know what the problem is; probably something so simple. Thanks, JL
 
Daniel, I guess Hotmail would not accept the email. Probably because it was so large. I cut down almost all the records. It is probably because I have so many forms. I will cut some of them and try again. Sorry about the trouble. Janet Lyn
 
Daniel, I went in and deleted about half my forms and it still stayed at 21,000Kb (7,098K)compressed. What could be taking all the space? JL
 
ok.... have you ever tried to "compact and repair" your database. This will decrease dramatically the size of your .mdb file. If it's still bigger than 2Mb, send it to me at this address daniel.bordeleau@fti-ibis.com
 
by the way, to heres the way to do that

Tools, Database Utilities, Compact and Repair Database
 
Actually, now that you mention it, I believe everytime I close my database it automatically compacts it. However, I have been having some funky things going on so I did that just the other day through the menus. But, just in case, I went to the file I was going to send you (not the zipped one) and did the Tools.....Repair Database. It came up with a note that says:

Table 'TempMSysAccessObjects' already exists.

And then it goes to my main menu, so I really don't think it repaired at all. I did a search from the code screen, telling it to find the above throughout the whole project and it said it could not find anything. Any suggestions? Thanks for your help, Janet Lyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top