Solved

Can't open Access reports with default printer

Posted on 2010-08-24
11
611 Views
Last Modified: 2013-11-28
This question is very similatr to the the problem stated in:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24670676.html.

I have a program that people use on various PCs. The actual printers will be network printers but vary depending on what department the person is working in .  If I set the report's "Use Specific Printer" to be the same as the default printer no problem. But if I tell the report to use the default printer, it doesn't work. It won't display in print preview. If I go to design view and hit the preview button. The report temporarily goes away and rather  than the Previewed report showing up, it goes right back to design view.  Based on the related thread above, I tried putting in the following code in the report's On Open event using the defailt printer mode:

10 PreviousPrinter = Application.Printer.DeviceName
20 Application.Printer = Application.Printers("HP LaserJet 4000 Series PCL 5 on COOLSERV1")
30 Application.Printer = Application.Printers(PreviousPrinter)

But it failed to work on line 20. Run Time Error 5. Invalid procedure call or argument"
Spent many hours on this so far and stumped.

Have to go to bed now, 12:16 AM EST, but will check this thread first thing in the morning.

Thanks,

John
0
Comment
Question by:askolits
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33518192
Quick thoughts:

1. Are you sure you have the printer name spelled correctly (as it appears on the Network)?
2. Is the printer Online at the time you are trying to Print?

3. Does this problem occur for all databases?, For all users?

4. FWIW, I found no hits on Google for "Application.Printers(PreviousPrinter)"
Are you sure this line is valid?
5. Where are you declaring: "PreviousPrinter"

6. Can you post the Entire code please?

;-)

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33518258
Oh,  ...I think the code in the previous Q will only work in Access 2002 and newer.
You need different code to do the same thing in Access 2000 and older.

Can you also state your Access version please?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 33518799
The Access version is crucial here in terms of the use of the code in the original post.
But I think we must be careful not to confuse the two issues - the 'printing problem ' and the ' code problem'

The operation of this bit of code is dependent on the Access version. As Jeff said you must have a version later than Access 2000 for this code to 'work'. I use the 'work' here because this code, in its effect, does nothing.  It records the current printer name, sets the default to a different printer and then immediately resets it back to the original name.
So the report will still try to print to the original default printer, not the one assigned by name in the code.

In respect of your posted printing problem, this 'do nothing' code might resolve it, as you say that if you set the report to the same specific printer then everything works ok.  

With regard to the code problem, I have found ACcess to be extremely picky with printer names and I just don't attempt to type them any more.  The problem with the code is almost certainly that Access does not recognise the printer name - not a helpful error message I know but that is my suspicion.

Run this bit of code (assuming Access 2002 or later) and copy from the immediate window and paste the required printer name between the "" in line 20.  Of course, it doesn't actually matter which printer name you choose because it is not used anyway.  

Sub allprts()
Dim prt As Printer
For Each prt In Application.Printers
Debug.Print prt.DeviceName
Next prt

End Sub






0
 

Author Comment

by:askolits
ID: 33519906
It's Access 2003. I'll try these various solutions. Thanks.
 
0
 

Author Comment

by:askolits
ID: 33520878
OK. Here's the latest.  I changed the name of the printer to "Microsoft XPS Document Writer" in the code above since I know everyone has that printer.  I first tried it at my home office. And it was working.
 I then remote desktoped to a computer on my customer's network and still a problem on that PC. I noticed the MDB was an Access 2000 DB running under Access 2003. I converted the mdb to a 2002-2003 format. Now what happens is when the default printer is "HP LaserJet 4000 Series PCL 5 on Coolserv1" (One of their network printers), I can't even go into design mode of the report. I select the report, select design and nothing happens. Change the default printer to any other printer, no problem. Remember that if I set the report to the Specific  Printer "HP LaserJet 4000 Series PCL 5 on Coolserv1", it works. But not everyone prints to that printer.
I looked at the network  printer permissions and gave everyone rights to all the printer functions but didn;t help. I'll still try a bunch of things on that end.
If anyone has any other ideas, let me know.
 
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 33522109
Here is some printer switching code, and also a procedure that lists the printer names as used in code:
Public Function ListPrinters()

   

   Dim prt As Access.Printer

   

   For Each prt In Application.Printers

      Debug.Print prt.DeviceName

   Next prt

   

End Function



Public Sub PrintToSpecificPrinter(strPrinter As String, strReport As String)

'Created by Helen Feddema 12-Feb-2010

'Last modified by Helen Feddema 12-Feb-2010



On Error GoTo ErrorHandler



   Dim prtCurrent As Printer

   Dim prtDefault As Printer

   

   'Save current default printer

   Set prtDefault = Application.Printer

   Debug.Print "Current default printer: " & prtDefault.DeviceName

   

   'Select a specific printer as new default printer

   Application.Printer = Printers(strPrinter)

   

   'Print the report

   DoCmd.OpenReport strReport

   

   'Set printer back to former default printer

   Application.Printer = prtDefault

      

ErrorHandlerExit:

   Exit Sub



ErrorHandler:

   MsgBox "Error No: " & Err.Number & "; Description: " & _

      Err.Description

   Resume ErrorHandlerExit



End Sub

Open in new window

0
 
LVL 77

Expert Comment

by:peter57r
ID: 33522128
I'm not competent in the area of remote working but I'm quite aware that in this setup printing is always a problem.
0
 

Author Comment

by:askolits
ID: 33525061
Helen thanks for the code, but I can't use a specific printer for the report.
 Update: It's a driver issue. The universal driver provided by HP won't work correctly with this older printer. Haven't been able to find the old driver any where yet on the web, but I did find an old "HP Laser Jet PS" printer in my Add Printer selection box on my personal PC. I then used a program called " Print Migrator Utility"  (for more info see - http://www.emergingtechs.com/posts/how-to-backup-printer-drivers-and-restore-them-on-another-computer/")
 
This backed up 'ALL' my drivers/printer selections on my PC into a CAB file. I then transferred that file to the remote PC and ran that program to restore all the drivers on the remote PC. Then I was able to add the older printer on the remote PC using 'Add Printer'.  
 
After that was finished, I made it my default and my Access reporting problem was gone. The only issue is that I only want to copy 1 driver not the many I had on my personal PC. The ultimate solution is finding an older driver.  Anyone know where I can find the older driver for free. "HP Laser Jet 4000 PS".  Not available from HP.
Or anyone know a way to copy just one driver from my PC to another PC?
 

0
 
LVL 14

Expert Comment

by:ldunscombe
ID: 33528465
Google "Driver Max"
Leigh
0
 

Author Comment

by:askolits
ID: 33557885
Everyone: It really looks like a driiver issue. Hopefully will have the solution resolved today. (Mon 8/31/2010)
0
 

Accepted Solution

by:
askolits earned 0 total points
ID: 33628483
Well, I installed one of the universal PS drivers from HP and it seems to work. The PLC drivers did not.  It was all very strange but I ended up resolving this issue myself.  Thanks all for your help.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now