Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / November 2008

Tip: Looking for answers? Try searching our database.

Print button in forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dino - 25 Apr 2006 22:33 GMT
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.
Denny - 25 Apr 2006 23:19 GMT
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

> 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.
Denny - 25 Apr 2006 23:36 GMT
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

> 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.
Dino - 25 Apr 2006 23:51 GMT
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,
>
[quoted text clipped - 21 lines]
> > 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.
Denny - 26 Apr 2006 16:33 GMT
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,
> I tried the code from your first reply and it worked great. I will use the
[quoted text clipped - 33 lines]
> > > 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.
Dino - 26 Apr 2006 22:07 GMT
Thanks Denny, it worked great!

> Hi Dino.
>
[quoted text clipped - 41 lines]
> > > > 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.
Serogen - 18 Nov 2008 14:59 GMT
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.

> Hi Dino.
>
[quoted text clipped - 41 lines]
> > > > 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.