Print button in forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like users to print, using a print button shown on my forms. I
already have the buttons created and properly labeled, and I have reports
already made for each of my forms. What VBA code do I enter in order to make
a print button actually print the report? Thanks.
 
Hi Dino,

Do you mean something like the following?

stDocName = "some_report"
DoCmd.OpenReport stDocName, acNormal

Then you just copy this code for each button and change out the report name
 
Hi Dino,

some further info, for me, Access autogenerates this code when I create the
button.
I'm including it all because my previous sample didn't include an error
handler or the declaration...which was bad on my part

On Error GoTo Err_Command5_Click

Dim stDocName As String

stDocName = "tblEmployer"
DoCmd.OpenReport stDocName, acNormal

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
 
Thanks Denny,
I tried the code from your first reply and it worked great. I will use the
additional code from this reply. One thing though, and this may be outside
the realm of Access, and more about the setup in my office:

When I click on the print button, it automatically starts printing to my
default printer in the office, without giving me the usual menu such as which
printer I want to print to, color vs. greyscale, etc. Is that something I
will just have to deal with?

Dino
 
Hi Dino.

To preview the report first use this command:
DoCmd.OpenReport stDocName, acPreview
Notice the only difference here is the acPreview.

hope that helps.
 
Thanks Denny, it worked great!


Denny said:
Hi Dino.

To preview the report first use this command:
DoCmd.OpenReport stDocName, acPreview
Notice the only difference here is the acPreview.

hope that helps.
 
This is exactly what I need. My only questions now (as stupid as it may
be)...WHERE do you enter these codes? I'm thinking Macro, "Action" and
"Argument", but that doesn't seem right. Does it go in the Visual Basic
window? fyi...I'm using Office 2007.
 
Back
Top