What's up with my printing?

ZedtheHead

No clue about Access user
Local time
Today, 12:57
Joined
Jan 11, 2005
Messages
15
I'm trying to print off a report after the user clicks on a button in a form. I created a macro to do this and it is set off in VB by

DoCmd.RunMacro ("PrintMacro")

It prints OK, but the trouble is that it also prints the form as well. What do I need to do to have it print ONLY the report?

:p
 
Printing

You don't need a macro for this.
Just create a button using the wizard.
You will see the option to print or preview a report and
it let's you select the report.
The code will be generated by the wizard.

Stay away from macros as much as you can.
One of the good reasons is that when using code you
can do error trapping, meaning you can keep control of the
program in case an error arises.
 
Thanks for the reply.

I put the print in a macro because the code in the button does some other stuff as well.

I tried putting DoCmd.PrintOut in the button's code but that printed the form.

How can I print out the report from the button in the form using VB?
 
Print

This is the code generated by the wizard:

Dim stDocName As String
stDocName = "yourreportname"
DoCmd.OpenReport stDocName, acNormal

For preview you can use this:

Dim stDocName As String
stDocName = "yourreportname"
DoCmd.OpenReport stDocName, acPreview
 
just been searching the forums and thought Id add to this post rather than start another

I have the same problem, but my macro runs from a switchboard, so there is not the option of adding a command button in and there is no option on the switchboard to print the report just open it, also, using this macro fits in with the final crieteria of my assignment!!

So when I run the macro on its own it works fine, opens the report hidden, prints it and closes it (and reopens the switchboard), when it runs from the switchboard, it also prints the page of the switchboard

so what options do I have to prevent this, I was hinking I could put the code on the open event of the report, to print the report and close is, therefore going back to the switchboard, but I wouldnt know what code to put in exactly
 
what have you actualy got in the macro?
It should print just the report not the switchboad if you have it set for openreport.

Peter
 
it was originally as follows:
openreport
printout
close

then I changed it to the following to see if it made any difference, this macro makes it so the switchboard isnt even open when the print command is given, but still it prints it

close (switchboard)
openreport
printout
close (report)
openform (switchboard)
 
arghh, more problems

just using the database on a different computer (still prints the switchboard)

on the same database, i also have a form, date selection type form, the user selects two dates on the form, presses a button at the bottom which is set to print a report, this report is linked to a query, so an input box pops up, takes the last bit of data then prints. The only problem is, it refuses to print to the default printer on the computer, it is stuck with printing to a remote printer on my other computer. The defaulkt printer is definatly set in windows!! confused
 
just use OpenReport
It prints by default but check the "Action Argument" is set to "Print"

You don't need the rest!
close (switchboard)
printout
close (report)
openform (switchboard)

HTH

Peter
 
for the printer, go to design view of the report,
File>Page Setup> select the Page Tab and make sure that "Default Printer" is selected

Peter
 
wow, fantastic, thanks a million!!! both problems solved:) :) :)
 

Users who are viewing this thread

Back
Top Bottom