Help revising code.

  • Thread starter Thread starter Denny G.
  • Start date Start date
D

Denny G.

Access 2002. The code that follows opens reports only.
Since I am a beginner at writing code, will one of you
experts show me the code I need to make this code open
both REPORTS and FORMS? Thank-you.

Private Function Preview()
On Error GoTo Preview_Err

If IsNull([ReportsList]) Or [ReportsList] = "" Then
MsgBox "You must select a report", 16, "Error"
DoCmd.GoToControl "ReportsList"
Exit Function
End If

DoCmd.OpenReport Me![ReportsList].Column(2),
acViewPreview
DoCmd.Maximize

Preview_Exit:
Exit Function

Preview_Err:
Select Case Err
Case 2501
Case 2202
MsgBox Error$
Case Else
MsgBox "Previewing report was Cancelled",
0, "Notice"
End Select
Resume Preview_Exit

End Function
 
Private Function Preview()
On Error GoTo Preview_Err

If IsNull([ReportsList]) Or [ReportsList] = "" Then
MsgBox "You must select a report", 16, "Error"
DoCmd.GoToControl "ReportsList"
Exit Function
End If

DoCmd.OpenReport Me![ReportsList].Column(2),
acViewPreview
DoCmd.Maximize

Preview_Exit:
Exit Function

Preview_Err:
Select Case Err
Case 2103 'No report to open with this name
Docmd.OpenForm Me.ReportsList.Column(2) 'Plus any other
Resume next

Case 2501
Case 2202
MsgBox Error$
Case Else
MsgBox "Previewing report was Cancelled",
0, "Notice"
End Select
Resume Preview_Exit

End Function
 
Back
Top