Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Posts
    292

    Unanswered: default printer...

    I have a form with a print button on there...

    When i hit it .. it prints fine on my PC... but if i move the access app(97) to a different station with different printer default it still prints on my printer..

    How can i change it to where it prints on the current printer default..

    heres my code behind print button..

    Private Sub Command15_Click()
    On Error GoTo Err_cmdPrint_Click

    Dim stDocName As String
    Dim MyForm As Form

    stDocName = "Form1"
    Set MyForm = Screen.ActiveForm
    DoCmd.SelectObject acForm, stDocName, True
    DoCmd.PrintOut
    DoCmd.SelectObject acForm, MyForm.Name, False

    Exit_cmdPrint_Click:
    Exit Sub

    Err_cmdPrint_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrint_Click
    End Sub


    thanks

  2. #2
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    If you have Windows XP then this might help, it works in ANY ms application (excel, word, access, outlook):


    Sub SetDefaultPrinter(InputPrinter As String)
    Dim WSHNetwork As Object
    Set WSHNetwork = CreateObject("WScript.Network")
    WSHNetwork.SetDefaultPrinter InputPrinter
    Set WSHNetwork = Nothing
    End Sub

    Sub ListAllPrinterinNetwork()
    Dim WSHNetwork As Object
    Dim oPrinters As Object
    Dim i As Byte

    Set WSHNetwork = CreateObject("WScript.Network")
    Set oPrinters = WSHNetwork.EnumPrinterConnections
    For i = 0 To oPrinters.Count - 1
    Debug.Print oPrinters.Item(i)
    Next
    '
    ' How to set default printer
    '
    End Sub


    WSHNetwork.SetDefaultPrinter ("\\Ken\Kens_Printer_hp4050")


    This if put in code somewhere will set a default printer, make sure you have a correct name !!!!!

    This code also gives Printers IP addresses

    Maybe you could use this to populate a listbox, then from the selection, set that printer as a default ??

    Be warned however that it will see the printer as a default in your Control box !! Not just in Access, so anything else you print from other apps will go there toi, until reset.

    Finally I didnt write this code, I have altered the original to suit my needs, and this is all I have...

    Hope it helps you.


    Ken

  3. #3
    Join Date
    Jul 2003
    Posts
    292
    thanks for the help.. will give this a try

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    The other thing you might check, in Page Setup for the report you can either print to the Default Printer or to a Specific Printer. On the Page tab of Page Setup is the option to pick either Default or Specific. If it is Specific then change it to default. You might have to change a control on the report then change it back to get it to save the setup.

  5. #5
    Join Date
    Jul 2003
    Posts
    292
    thanks.. i acutally did go into page setup and changed it there.. works fine now ..

    thanks !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •