VBA Print Error (1 Viewer)

kitty77

Registered User.
Local time
Yesterday, 20:22
Joined
May 27, 2019
Messages
712
I have a print button on a report. Just recently, I'm getting an error when I click the button.
When I click it a second time, it prints just fine. Anyone experience anything like this?

This just starting happening in the last week or so...

1647054165794.png


1647054217898.png
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:22
Joined
Feb 28, 2001
Messages
27,243
First question: Do you, at the moment you do this, have a "default" printer selected?
 

kitty77

Registered User.
Local time
Yesterday, 20:22
Joined
May 27, 2019
Messages
712
Yes, I do have a default printer.
 

kitty77

Registered User.
Local time
Yesterday, 20:22
Joined
May 27, 2019
Messages
712
And it's happening on a few other workstations too. Windows update? Virus protection update?
 

Eugene-LS

Registered User.
Local time
Today, 03:22
Joined
Dec 7, 2018
Messages
481
I have a print button on a report. Just recently, I'm getting an error when I click the button.
Try that command:
Code:
DoCmd.OpenReport "Your Report Name", acViewNormal
...
acViewNormal - Sends report to default printer (usually), or some sting wrong in your application.
Does it compile normally?
 
Last edited:

kitty77

Registered User.
Local time
Yesterday, 20:22
Joined
May 27, 2019
Messages
712
The report is already open to specific record, not sure that works here.
 

kitty77

Registered User.
Local time
Yesterday, 20:22
Joined
May 27, 2019
Messages
712
But this does not give me the opportunity to select a printer?
 

LarryE

Active member
Local time
Yesterday, 17:22
Joined
Aug 18, 2021
Messages
593
If you open the report in PrintPreview mode, you will be given the chance to select a printer before printing and you see what the report looks like. Always a good idea before you print something.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:22
Joined
Feb 28, 2001
Messages
27,243
If you wish to select a printer ahead of time, look at Application.Printers, which is a collection of printers (by name) that you can select for your next print operation. I recall we had some recent threads on interacting with printers with that .Printers collection and also with the WMI library (Windows Management Interface) that allows you to get to printer properties. Search the forum for PRINTERS and see what pops up. Since the posts show dates when you get the list, you can limit yourself to about the last year. You should be able to find what you want. Just do the printer adjustments BEFORE you trigger the print job.
 

LarryE

Active member
Local time
Yesterday, 17:22
Joined
Aug 18, 2021
Messages
593
You can also open the print dialog box first and select a printer using:
Application.CommandBars.ExecuteMso ("PrintDialogAccess")
 

Users who are viewing this thread

Top Bottom