Print report help

  • Thread starter Thread starter Chad
  • Start date Start date
C

Chad

Hello, I have a report that has several pages and most of the time I only
want to print 1 page. Well im using a custom menu since I have the DB menu
turned off. The type im using is a popup so when I right click on my report
it brings up my custom menu. Anyway, I can find and add the print button to
my custom menu but when i go to use it, it never gives me an option of Page
of Pages so I can select 1 of 1 so it will print out 1 page. What I get is it
just prints every page and that sometimes could be 100 pages! What setting am
I missing to acomplish this? Thanks~
 
Hi Chad,

When your report is opened and you want to print specific pages, use ctrl+P
and that will bring up the print option like selecting it from the file menu.
 
Stockwell43, that works good for now but I need this fixed. I have several
employees that would use this and to choose an option like print would be
easer than asking them to ctrl/P. Is there a nother way or is this what im
looking at? Thanks!
 
Honestly Chad, I really don't know because I always leave the default toolbar
with File in the report. I would imagine there may be a workaround or to some
how program it to work the way you need it to but that is beyond me. Sorry I
couldn't be more help.
 
Well mabe someone has an answer but for now it works at least! I thank you
for your help...
 
You're quite welcome! I agree, sometimes the band aid solutions are better
than no solutions at all.
 
The follwig code is run by my custom report menu

The select object command is needed to fix a "focus" bug if you have a form
with a timer function.

For the code that pops up the printer dialog (so the user can change
printers, choose pages etc).

You can use:

On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint

The select object command is needed to fix a "focus" bug if you have a form
with a timer function.

The code to print right to the printer while in preview mode can be:

On Error Resume Next
Dim strReportName as string
strREportName = Screen.ActiveReport.Name
DoCmd.SelectObject acReport, strReportName
DoCmd.PrintOut acPrintAll
 
Hi Albert,

So the first piece of code will bring up the dialog box as if you selcet
File and Print from the File menu? If so, where would you place this code? If
I wanted to use this in place of exposing the toolbar, where do this code go,
in the report somewhere?

Thanks!!
 
Yes good question/ Wher is the cod placed? You cant use buttons on the
reports so where would it go?
 
Ok I got it! here is what I did. I created a module named basPrintSuperlog
and added this code:

Option Compare Database
Option Explicit

'Code works with macro mcrPrintSuperlog
'This code is so I can get a print dialog box for my report

Function PrintSuperlog() As String
On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint
End Function

Then I created a macro named mcrPrintSuperlog and used the:
1) Action: Run Code
2) Function name: PrintSuperlog()

Then I created a custom popup button Tools/Customize/New and I named it
Print Superlog. Then I select the buttons properties and in its on action I
selected the mcrPrintSuperlog macro I created. Then I set the buttons Type to
Popup. I then went to my report and in the properties I selected All/Shortcut
Menu bar/ Print Superlog "The name of my button" Hops this helps others who
have this problem!
 
Nice work Chad! I'll save the information and try it on a new database I am
working.

Thanks for the help!
 
Chad said:
Yes good question/ Wher is the cod placed? You cant use buttons on the
reports so where would it go?

Standard code module (you posted a response to this question already)



here some more info:

You do NOT need your menu bars to call macros..you can have them call VBA
code direct....

Here is a screen shot of a menu bar I use for ALL reports:
http://www.members.shaw.ca/AlbertKallal/test/bu.htm

I would say that 90% of my custom menu bars call, and run my VBA code.

All you need to do is make the code (a function) public, and then simply
place the function name in the buttons on-action event code.

Further, likely often you will have specific code to a particular form, and
once again, you simply declare those functions (in that form) as public.

The syntax to call the code then is:

=YourFunctionName()

Often, (if not most of the time), you code you call will need to pick up
some information about he current screen etc. So, my code most of the time
starts out, and grabs the current screen name. I use:

Public Function AskInvoicePrint()

Dim tblgroupid As Long
Dim frmActive As Form

Set frmActive = Screen.ActiveForm

tblgroupid = frmActive.frmMainClientB.Form!ID

If frmActive.InvoiceNumber = 0 Then
frmActive.InvoiceNumber = nextinvoice
frmActive.Refresh
End If

DoCmd.OpenForm "guiInvoicePrint", , , "id = " & tblgroupid

End Function

The above is code that the invoice print button runs. note how I right away
pick up the active form. After that, I can easily ref the forms object as if
the code was running much like the code would if put behind a button on the
form. In the above example, I also check if a invoice xnumber has been
generated before printing. And, the Refresh forces a disk write if in fact I
do change the invoice number. And, in addition the above clip also passes
the currently selected sub-form item that the invoice print form needs.

Also, if the code you write is for the particular form, then as mentioned,
you can simply place the code into the forms module code. There is no need
to pick up the active screen...and you can use me. as you
always used.

If you want to see some sample menu bars, and why I use them, you can read
the following:

http://www.members.shaw.ca/AlbertKallal/Articles/UseAbility/UserFriendly.htm
 
Back
Top