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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer Dialog 1

Status
Not open for further replies.

kashew

Programmer
Feb 22, 2001
35
US
Does Access97 have a printer dialog box available? I need the ability for the user to change the printer destination before executing a macro that prints 8 reports. I don't wish to use print preview.

If there isn't a dialog available, I need some sample code on accessing the windows api to accomplish this.
 
hmm...thats my question as well. Thanks for posting this hopefully someone will respond. I don't think access has a printer dialog, but I'm not fairly sure, since its such a larger program.
 
Hi!
There are codes for printer setup by using Common Dialog control. You may create Common Dialog control object on your form before running this codes. (MSCOMCTL.OCX)

Private Sub pbPrinter_Click()
On Error GoTo Err_pbPrinter_Click
Dim objDialog As Object
Dim BeginPage, EndPage, NumCopies, i

Set objDialog = Me.cmnDialog.Object

With objDialog
.CancelError = True
.DialogTitle = "Printer Setup Sample"
.flags = 0 ' &H8 Or &H4 Or &H80000 Or &H0
.ShowPrinter
' Get user-selected values from the dialog box
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
For i = 1 To NumCopies
' Put code here to send data to the printer
Next i
End With

Exit_pbPrinter_Click:
Exit Sub

Err_pbPrinter_Click:
If Err.Number <> 32755 Then 'Cancel action
'MsgBox &quot;Error No &quot; & Err.Number & vbLf & Error$
End If
Resume Exit_pbPrinter_Click
End Sub

Aivars
 
Thanks for the code. When I drop the MS Common Dialog Control on my form, I get a error that says I have no license to use it. The file MSCOMCTL.OCX, however, exists on the hard drive. What's the problem?
 

Some versions of the Common Dialog Control come with Professional Developer products such as Access ODE and Visual Studio. If you aren't licensed for those programs you can't use the Control for development. Ther is a very easy way to bring up the print dialog in Access 97. Execute the following code from a module.

DoCmd.RunCommand acCmdPrint Terry
Please review faq183-874.

&quot;The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge.&quot; - Daniel J Boorstin
 
This works like a charm! One simple command. I like it. Thanks!!!
 
How can I scale my Report in Preview mode and then print it out if printer driver doesn’t support dmScale in prtDevMode. If I open printer Property dialog box there is a Zoom option to set but I cannot reach it from the code and the Preview mode still not scaled. I need to do this from the code only. Please HELP!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top