Show Access Print Dialog to Ask for a Printer

F

flores

Using Access 2002

I used the command wizard to create a button on the form to print the form's
currently selected record. The record prints fine, but it does not allow
selecting of a printer. I want to let users select a printer, and then use
the code that the Toolbox Wizard created to print the selected record (code
attached).

Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_cmdPrint_Click:
Exit Sub

Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click

End Sub
 
P

Piet Linden

Using Access 2002

I used the command wizard to create a button on the form to print the form's
currently selected record.  The record prints fine, but it does not allow
selecting of a printer.  I want to let users select a printer, and thenuse
the code that the Toolbox Wizard created to print the selected record (code
attached).

Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.PrintOut acSelection

Exit_cmdPrint_Click:
    Exit Sub

Err_cmdPrint_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrint_Click

End Sub

Any reason prompting the user with a modal form won't work? Then you
can just populate a combo or listbox with the available printers...

Private Sub cmdListPrinters_Click()
Dim ptr As printer
Dim intCounter As Integer

For Each ptr In Application.Printers
Me.cboPrinters.AddItem ptr.DeviceName, intCounter
intCounter = intCounter + 1
Next ptr

End Sub

Then you could use it in this...
http://www.allenbrowne.com/AppPrintMgt.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top