Results 1 to 4 of 4
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Select a temp printer from combobox, load default printer when form closes

    Hey guys,

    InstalledPrinters is the combo box

    I have this code on the mouse down for the combo box (got it off a google search):


    Code:
    Dim pr As Printer
    For Each pr In Printers
        Me.InstalledPrinters.AddItem pr.DeviceName
    Next pr
    Me.InstalledPrinters.Text = Printer.DeviceName
    For the click event I tried (made this up myself):
    Code:
    Private Sub InstalledPrinters_Click()
    Dim NewPrinter As String
    NewPrinter = Me.InstalledPrinters
    Set Application.Printer = Application.Printers(NewPrinter)
    End Sub
    And I have these on the form load/unload:
    Code:
    Private Sub Form_Load()
    Dim DefaultPrinter As String
    DefaultPrinter = Application.Printer.DeviceName
    Me.SalesName = Me.SelectEmp.Column(1)
    End Sub
    Code:
    Private Sub Form_Unload(Cancel As Integer)
    Set Application.Printer = Application.Printers(DefaultPrinter)
    End Sub

    The combo box list code seems to work. But the click event code doesn't seem to do what its supposed to. Any thoughts on what I should do differently?
    Last edited by June7; 02-25-2014 at 11:47 AM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    What do you mean by 'doesn't seem to do what its supposed to', what happens - error message, wrong results, nothing?

    Have you step debugged?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    After more careful look I've noticed the combo box is also having issues. The list of printers gets duplicated every time you drop down the combo box list. It resets every time you exit the form, or go into design view.

    Clicking on a printer in the list doesn't change the selected printer in the list (that sentence make sense?).

    I haven't really been able to test the switch back to the default printer from the new printer since I can't get the combobox to work.

    No errors pop up. Pretty much, nothing happens after the combo box populates.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    The list of printers duplicates because the procedure runs with every mouse down on the combobox, it just appends items. Suggest a different event, like form Open.

    Try AfterUpdate instead of Click event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Select Default Printer
    By pkstormy in forum Code Repository
    Replies: 4
    Last Post: 03-10-2015, 09:26 AM
  2. Print to Default Printer
    By bsc0617 in forum Access
    Replies: 7
    Last Post: 10-10-2013, 07:46 AM
  3. Replies: 15
    Last Post: 09-06-2012, 06:25 PM
  4. Trying to Change Default printer
    By sims.anderson2010 in forum Programming
    Replies: 2
    Last Post: 03-08-2012, 08:07 AM
  5. Forms to Printer
    By Roland in forum Reports
    Replies: 1
    Last Post: 11-22-2010, 10:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums