I use an option group with a Print button and a Preview button to allow the user to select the different reports and whether they want to print it or just preview it. The code looks like this:
Private Sub cmdPreview_Click()
On Error GoTo ErrorPreview
Select Case [fraPrint]
Case Is = 1
DoCmd.OpenReport "rptOpen", acViewPreview
Case Is = 2
DoCmd.OpenReport "rptOverdue", acViewPreview
Case Is = 3
DoCmd.OpenReport "rptTrend", acViewPreview
Case Is = 4
DoCmd.OpenReport "rptClosed", acViewPreview
Case Else
MsgBox "Please chose a report to view", vbExclamation, _
"Suspenses"
End Select
ExitPreview:
Exit Sub
ErrorPreview:
Select Case Err.Number
Case 2501
Resume ExitPreview
Case 2603
MsgBox "You do not have access to this department's suspenses", _
vbExclamation, "Access Denied"
Case Else
MsgBox Err.Description
Resume ExitPreview
End Select
End Sub
The code for the print button is the same except for the acViewPreview is acViewNormal.
If I click on the Preview button to look at a report, then click on the Print button (the one on the form) while the report is still open, the report changes to design view and prints. Does anyone know why it's opening in design view and how to keep it from doing it?![[ponder] [ponder] [ponder]](/data/assets/smilies/ponder.gif)
Thanks!
Linda Adams
Linda Adams/Emory Hackman Official Web site Official web site for actor David Hedison:
Private Sub cmdPreview_Click()
On Error GoTo ErrorPreview
Select Case [fraPrint]
Case Is = 1
DoCmd.OpenReport "rptOpen", acViewPreview
Case Is = 2
DoCmd.OpenReport "rptOverdue", acViewPreview
Case Is = 3
DoCmd.OpenReport "rptTrend", acViewPreview
Case Is = 4
DoCmd.OpenReport "rptClosed", acViewPreview
Case Else
MsgBox "Please chose a report to view", vbExclamation, _
"Suspenses"
End Select
ExitPreview:
Exit Sub
ErrorPreview:
Select Case Err.Number
Case 2501
Resume ExitPreview
Case 2603
MsgBox "You do not have access to this department's suspenses", _
vbExclamation, "Access Denied"
Case Else
MsgBox Err.Description
Resume ExitPreview
End Select
End Sub
The code for the print button is the same except for the acViewPreview is acViewNormal.
If I click on the Preview button to look at a report, then click on the Print button (the one on the form) while the report is still open, the report changes to design view and prints. Does anyone know why it's opening in design view and how to keep it from doing it?
![[ponder] [ponder] [ponder]](/data/assets/smilies/ponder.gif)
Thanks!
Linda Adams
Linda Adams/Emory Hackman Official Web site Official web site for actor David Hedison: