Printing a report from an homemade inputbox

rosenn

Registered User.
Local time
Today, 10:20
Joined
May 6, 2002
Messages
45
I abandoned the Access inputBoxes in lieu of a home-made version (an unbound form) that I have a print button at the bottom to print multiple copies of a report. Here is the heart of the code (to print NumPatrons #of the report MABriefList):

If NumPatrons <= 0 Then GoTo ExitTournee
DoCmd.OpenReport "MABriefList", acViewPreview
For Counter = 1 To NumPatrons
DoCmd.PrintOut acPrintAll, , acHigh
Next Counter
DoCmd.Close acReport, "MABriefList"

Here is the problem. When the main switchboard (yes, I won't be using those again either) opens my little inputbox, somehow a user managed to print the switchboard and not the MABrieflist. Should I have 'handled' the switchboard window somehow ? Also, why can't I simply use
DoCmd.Printout acPrintAll, , acHigh, NumPatrons ? That did not work.

All help greatly appreciated.
 
You can set the Switchboard form visible property to false just before you open the report, and set the switchboards visible property to true on the Report_Close Event.

Also the Docmd.PrintOut does have a Copies parameter. You can set this to the number of copies you want printed so that you don't have to use a for...loop.
 
Got it working

I don't know why the DoCmd.Printout printed my switchboard, but I have used code to set the Switchboard to invisible, then back again after printing. It works just fine. Also, I got the copies parameter to work again. This old system is a bit buggy, and its a bit difficult because my Access is in French. But I digress..


Thanks again.

Nelson
 
The Docmd.PrintOut uses the Object (in this case Form or Report) that currently has the Focus. It is possible that the user is somehow clicking on the Switchboard giving it the focus prior to the PrintOut command. The Switchboard could have its modal property set (This keeps it on top).

Another possiblility is to put the docmd.Maximize on the Report_Open Event and the Docmd.Restore on the Report_Close Event.

This would make the report take up the entire Access window and then restore the windows to their normal state on the closing of the report.
 

Users who are viewing this thread

Back
Top Bottom