Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000 Set Printer 2

Status
Not open for further replies.

Taff82

Programmer
Feb 11, 2004
43
GB
Hi All,

I have searched this Forum and unfortunately not to much luck.

I'm not sure if this is possible but here goes. I have a form with a command button on and when the command button is clicked I would like to Print 1 copy of a report to 3 different printers. %-)

This has to be done without the user doing anything besides clicking on the command button.

Thanks in Advance for any help.

Regards,

Ant.
 
Taff82,

I found this thread that speaks about changing printers programatically in access. I can't verify for the code as I haven't tried it, if it doesn't work or you have more questions, please post back.

thread707-837771

Fred
 
Taff82

Hmmm.

In a past life, when I worked with Informix, we would actually store the printer information in a table. This was with Unix systems - a lot tougher than with Windows (sidebar: Windows sure made it easier to print, and for sharing drivers).

I suspect this approach may work here too. I am not sure of your OS, but you could store the pritner info in a table (printer name, print queue or IP address), maybe event setup a printer interface where you can assign a report to a printer(s).

This approach would work well for "pick-lists", "bill-of-lading" or other production / shipping documents where a customer service rep takes the order, and the requried documentaiton prints elsewhere (not to the end user's default printer).

Richard
 
These 2 functions get and set the default printer for the whole PC.
I use them as:
strActivePrinter=GetDefaultPrinter()
SetDefaultPrinter("DocuCom PDF Driver,winspool,LPT1:")
at the start of the routine then
SetDefaultPrinter(strActivePrinter)
at the end

I've used them successfully with NT and XP and the best thing is that it works with whatever file you like!

hth

Ben

Code:
Function GetDefaultPrinter()
Dim oShell
Dim sRegVal
Dim sDefault
  Set oShell = CreateObject("WScript.Shell")
  sRegVal = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
  sDefault = ""
  On Error Resume Next
  sDefault = oShell.RegRead(sRegVal)
  On Error Goto 0
  GetDefaultPrinter = sDefault
End Function

Function SetDefaultPrinter(strPrinter)
Dim oShell
Dim sRegVal
  Set oShell = CreateObject("WScript.Shell")
  sRegVal = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
  On Error Resume Next
  oShell.RegWrite sRegVal,strPrinter
  On Error Goto 0
End Function

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top