How can I automate printing from a command button with selected data from a query? (1 Viewer)

DeborahQuest

New member
Local time
Today, 08:47
Joined
Jul 15, 2013
Messages
7
How can I automate different printers for different reports on the same MS Access 2007 database, without having to select the printer each time?

There are two reports that are printed on the same database. Previously, I had automated form buttons to print the reports, without having to select the printer each time. This was about 8 years ago, but I don't remember how I did this. Also, I don't know SQL. Nothing against code, but I did not know how to program, and just MS Access 2007 access itself. Thanks for your help in advance.
Deborah Quest
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:47
Joined
Aug 30, 2003
Messages
36,118
I moved your thread to a more appropriate forum. In Page Setup you can specify a specific printer rather than the user's default printer. Is that what you're after?
 

DeborahQuest

New member
Local time
Today, 08:47
Joined
Jul 15, 2013
Messages
7
Dear PBaldy,

Thanks for the reply. I have tried that, but every time that I am ready to print, the print dialogue box opens up again asking for which printer to select. Before, it just used to print directly to the printer that the command button on my form was set to. Crazy thing is when I did this 8 years ago, I swear I didn't use SQL, cause I don't know that. :confused:
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:47
Joined
Aug 30, 2003
Messages
36,118
What is the code behind your button?
 

DeborahQuest

New member
Local time
Today, 08:47
Joined
Jul 15, 2013
Messages
7
Dear Paul,

Thanks so much for your help. Below is the code on the command button. Again, I did not do this. I don't know code. :(

Private Sub Command45_Click()
On Error GoTo Err_Command45_Click
Dim stDocName As String
stDocName = "Bottle Labels"
DoCmd.OpenReport stDocName, acNormal
Exit_Command45_Click:
Exit Sub
Err_Command45_Click:
MsgBox Err.Description
Resume Exit_Command45_Click

End Sub
 
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:47
Joined
Aug 30, 2003
Messages
36,118
Does the user have a default printer defined? That code should just print the report out to the default printer.
 

DeborahQuest

New member
Local time
Today, 08:47
Joined
Jul 15, 2013
Messages
7
Does not even go to the default. Dialogue box opens. Each printer is there listed, even the old ones that are no longer linked to the printer, but which the command button was printing from before. Thank you.
 

Users who are viewing this thread

Top Bottom