473,797 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use multiple printers in MSACCESS

222 New Member
Hello everybody


I do have a form called invoices I'm using a this code to print a report called invoices

Expand|Select|Wrap|Line Numbers
  1.    DoCmd.OpenReport "Invoices", acViewPreview, "", "[Forms]![Invoices]![InvoiceID]=[InvoiceID]", acHidden
I do have 2 printers installed in my computer "HP" and "Epson "
How can I ask user before he prints the invoices report to chose which printer want to use ...???
is there any method that can find all printers installed on the computer and let user choose the one that he needs to use ????
I'm using windows xp SP2 and Microsoft access 2003


thank you to all
Nov 10 '07 #1
2 4470
ADezii
8,834 Recognized Expert Expert
Hello everybody


I do have a form called invoices I'm using a this code to print a report called invoices

Expand|Select|Wrap|Line Numbers
  1.    DoCmd.OpenReport "Invoices", acViewPreview, "", "[Forms]![Invoices]![InvoiceID]=[InvoiceID]", acHidden
I do have 2 printers installed in my computer "HP" and "Epson "
How can I ask user before he prints the invoices report to chose which printer want to use ...???
is there any method that can find all printers installed on the computer and let user choose the one that he needs to use ????
I'm using windows xp SP2 and Microsoft access 2003


thank you to all
  1. Populate a Combo List with a List of available Printers for the User to select from.
    Expand|Select|Wrap|Line Numbers
    1. Dim prn As Printer
    2.  
    3. Me![cboInstalledPrinters].RowSourceType = "Value List"
    4.  
    5. For Each prn In Application.Printers
    6.   'Populate a Combo Box with a list of Installed Printers
    7.   Me![cboInstalledPrinters].AddItem prn.DeviceName
    8. Next
    9.  
  2. Assign the specifically chosen Printer to the Report.
    Expand|Select|Wrap|Line Numbers
    1. If Not IsNull(Me![cboInstalledPrinters]) Then
    2.   'Open Hidden so you can assign a specific Printer to the Report
    3.   DoCmd.OpenReport "rptShippers", acViewPreview, , , acHidden
    4.     'assign selected Printer
    5.     Set Reports!rptShippers.Printer = Application.Printers(Me![cboInstalledPrinters].ListIndex)
    6.   'Print the Report
    7.   DoCmd.OpenReport "rptShippers", acViewNormal, , , acWindowNormal
    8. End If
    9.  
Nov 11 '07 #2
bany
4 New Member
Hi!
First of all create a module Name: PrintersList and place this code incide:
=============== =============== =============== =========
Option Compare Database
Option Explicit
Private Declare Function GetProfileSecti on _
Lib "kernel32" Alias "GetProfileSect ionA" _
(ByVal lpAppName As String, ByVal lpReturnedStrin g As String, _
ByVal lngSize As Long) As Long

Private Const adhcMaxSection = 10000
Function PrinterChooser( ) As String

Dim strMatchstr As String
Dim strItems() As String
Dim strPrinters() As String
Dim strDetails() As String
Dim NoPrinter(20) As String
Dim AutoPrinter(20) As String
Dim PrinterPort(20) As String
Dim list As String
Dim strBuffer As String
Dim intCount As Integer
Dim i As Integer

On Error GoTo HandleErrors
strBuffer = Space(adhcMaxSe ction)
intCount = GetProfileSecti on("Devices", strBuffer, adhcMaxSection - 1)
strMatchstr = Left$(strBuffer , intCount)
If Len(strMatchstr ) = 0 Then
intCount = 0
Else
strPrinters = Split(strMatchs tr, vbNullChar)
ReDim aDevList(LBound (strPrinters) To UBound(strPrint ers))
For i = LBound(strPrint ers) To UBound(strPrint ers)
If Len(strPrinters (i)) > 0 Then
strItems = Split(strPrinte rs(i), "=")
NoPrinter(i) = strItems(0)
strDetails = Split(strItems( 1), ",")
AutoPrinter(i) = strDetails(0)
PrinterPort(i) = strDetails(1)
list = list & NoPrinter(i) & ";" _
& AutoPrinter(i) & ";" & PrinterPort(i) & ";"

End If
Next i
End If

ExitHere:
PrinterChooser = list
Exit Function

HandleErrors:
Select Case Err.Number
Case Else
Err.Raise Err.Number, Err.Source, Err.Description
End Select
End Function

Function DefaultPrinter( ) As String

Dim strMatchstr As String
Dim NoPrinter As String
Dim strBuffer As String
Dim intCount As Integer
Dim i As Integer
Dim PosDeb As Integer
Dim PosFin As Integer
Dim Longueur As Integer
On Error GoTo HandleErrors
DefaultPrinter = ""
strBuffer = Space(adhcMaxSe ction)
intCount = GetProfileSecti on("Windows", strBuffer, adhcMaxSection - 1)
strMatchstr = Left$(strBuffer , intCount)

If Len(strMatchstr ) = 0 Then
intCount = 0
Else
PosDeb = InStr(1, strMatchstr, "Device=", vbTextCompare) + 7
PosFin = InStr(PosDeb, strMatchstr, ",", vbTextCompare)
Longueur = PosFin - PosDeb
DefaultPrinter = Mid(strMatchstr , PosDeb, Longueur)
End If

ExitHere:
Exit Function

HandleErrors:
Select Case Err.Number
Case Else
Err.Raise Err.Number, Err.Source, Err.Description
End Select
End Function

=============== =============== =============== ========
1-After this module create a form Name: PrinterChooser
And then incide the form create 1 text box name it:DefaultPrint er
go to data...control source and put this : =DefaultPrinter ()
=============== =============== =============== ========
2-And then create a conboBox Name it:PrinterList
go to format.....Colu mn count=3 and then to .......Column Width=1.575";0. 7875";0.7875"
=============== =============== =============== ========
3-go to event of the combo box OnClick put this:
=============== =============== =============== ========
Option Compare Database
Private Declare Function WriteProfileStr ing _
Lib "kernel32" Alias "WriteProfileSt ringA" _
(ByVal lpszSection As String, ByVal lpszKeyName As String, _
ByVal lpszString As String) As Long

Private Declare Function SendMessageTime outStr _
Lib "user32" Alias "SendMessageTim eoutA" _
(ByVal hwnd As Long, ByVal msg As Long, _
ByVal wParam As Long, ByVal lParam As String, _
ByVal fuFlags As Long, ByVal uTimeout As Long, _
lpdwResult As Long) As Long


Private Const WM_WININICHANGE = &H1A
Private Const SMTO_NORMAL = &H0
Private Const HWND_BROADCAST = &HFFFF&

Private Sub Form_Load()
Me.PrinterList. RowSource = PrinterChooser( )
End Sub

Private Sub PrinterList_Cli ck()
Dim strBuffer As String

strBuffer = Me.PrinterList. Column(0) & "," & _
Me.PrinterList. Column(1) & "," & Me.PrinterList. Column(2)

Call WriteProfileStr ing("Windows", _
"Device", strBuffer)
Call SendMessageTime outStr(HWND_BRO ADCAST, WM_WININICHANGE , _
0, "Windows", SMTO_NORMAL, 1000, 0)
Me.DefaultPrint er.Requery
End Sub

=============== =============== =============== ===========
Jan 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5893
by: Aaron_TekRecycle.com | last post by:
Someone must have done this before?!? I have VBS code that will Enumerate all the Printers in the AD and Add the Printer Connection to the client... I'm just not a web developer so I need some example code or hand-holding on the web integration portion. Anyone? "Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
1
6102
by: Mark | last post by:
I have the following xml file that I want to read in using vb.net 2003: <dordivision name="district 1" propname="District 1"> <printer id="location11" duplex="false">Location 11</printer> <printer id="location12" duplex="true">Location 12</printer> <printer id="location13" duplex="true">Location 13</printer>
1
2889
by: TheThrill | last post by:
I've got a report, Report1 that i want to print to network Printers A, B, C all with one key stroke. How do i do this?
4
1942
by: DS | last post by:
Does anyone know about or how to set up multiple printers. I have an order form that has different items on it. The thing is I want different items on that order form to go to different printers when a command button is pressed. Thanks. DS
9
2103
by: Tom Weston | last post by:
Help I have 4 databases containing different data relating to safety, not written by me. It is not possible to merge the databases into one large data base. I would like to create a user interface with 4 buttons, one for each database. The aim would be for the user to click on a button and the related database opens for use. When the database is closed the user interface with the buttons on returns. Can anybody offer a method of achieving...
7
9080
by: trint | last post by:
How can I add all the network printers to a combobox? Thanks, Trint
0
1543
by: James Redd | last post by:
Hi, I am looking for a good book or source of information on how to best setup a multiple printer gui. The application I'm working on runs on a server where each user has their own login. The application requires a printer to be defined for "WorkOrders", "Checks", "Invoices". Currently these are all specified in an ini file in the active directory for each user. I need to build a gui for the user to select which printer they want to use...
0
1589
by: Ravigwipro | last post by:
Hi, I m able to get the printers object to know what are the printers had been installed and all. here my requirement is i have to write a data from VB to MS Word. for the page setup i have to get printer info. problem here i m facing is , i m getting the printer info and am able to write the complete document in that case it is working fine..but while generation of document if it gets fail due to some runtime error, in the immediate run...
4
5278
by: Frank Rizzo | last post by:
I basically need a list of printers that's returned by the Find Printers dialog ( http://www.sqleffects.com/mystuff/findPrinters.png ). I've tried the path of DirectoryEntry entry = new DirectoryEntry(strPath); DirectorySearcher mySearcher = new DirectorySearcher(entry); mySearcher.Filter = "(objectCategory=printer)" foreach(SearchResult result in mySearcher.FindAll()) { strName = result.GetDirectoryEntry().Name;
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10468
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.