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

Print report from form...provide Print Dialog Box, too

Status
Not open for further replies.

NRK

Technical User
Feb 13, 2002
116
US
I have a pop-up form that allows users to filter a report. On the form, I have a Print command that prints out the report.

Code:
stDocName = "RPT_ST003"
DoCmd.OpenReport stDocName 'Prints report without Dialog box...


I need to allow users to access the Print Dialog box when they click Print. Unfortunately, I cannot figure out how to do this. I have tried incorporating the code above with DoCmd.RunCommand acCmdPrint. This does allow users to see the Print Dialog box, but prints the form and not the report.

Does anyone have any ideas? I am stuck and don't know what else to try.

Thank you.
 
You can use the microsoft common dialogs. These include the standard windows printer dialog. I think the resource on my machine is Microsoft Dialog Automation Objects. JHall
 
JHall
Thanks for the feedback. I had read a little bit about that, but don't know enough to make this work.

Can you provide some additional information on how to incorporate MS common dialogs?
 
NRK,

The Print Common Dialog is next to useless in Access. Best advice is not to bother!

Craig
 
Craig,
Do you have any advice as a work around? We have multiple printers in house and each user will want the option to print to selected printers.

There has to be some way...
 
Yep....

Reports will print to their default Windows printer. So different default printers means different places. It really is up to the user to define a sensible default printer.

The Print Common Dialog is VERY difficult to work with from Access....

Craig

 
Craig,
Thanks for the follow-up. I found a code snippet that I modified for my use (thanks to Aivars). It seems to be working and should hopefully provide enough functionality to satisfy my users.

I appreciate your advice and if you have any more thoughts about the Print Common Dialog, I would like to hear them.

If anyone is interested, this is the code I am using:
Private Sub cmdPrint_Click()
On Error GoTo printerr
Dim intMsg As Integer

If Not IsNull(cbotcCategory) Then
intMsg = MsgBox("This will open a form that will allow you to filter the records and print them in a report.", vbInformation)
DoCmd.OpenForm FormName:="Filter_001"
Exit Sub
Else
MsgBox "You must select a valid Category to print.", vbInformation
DoCmd.GoToControl "cboTcCategory"
Exit Sub
End If


printerr:

Select Case Err
Case 2501
Exit Sub
Case Else
End Select

Exit Sub
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top