L
Leif Hole
I have tried to use some code that I found in earlier postings but I cant
get it to work, I have tripple checked for spelling errors....
I use Access XP
Leif Hole, Norway
Here is what I use, from Joe Fallon:
This is a good way to handle the no data event for a report.
Note that the Print Preview button has to trap error 2501 when the code sets
Cancel=True.
====================================================
Private Sub Print_Preview_Click()
On Error GoTo Err_Print_Preview_Click
Dim DocName As String
DocName = [Forms]![Report Menu]![RptList]
DoCmd.OpenReport DocName, acViewPreview
Exit_Print_Preview_Click:
Exit Sub
Err_Print_Preview_Click:
Select Case Err.Number
Case 2501
MsgBox ("There is no data for this report.")
Case Else
MsgBox ("Error # " & Str(Err.Number) & " was generated by " &
Err.Source & Chr(13) & Err.Description)
Resume Exit_Print_Preview_Click
End Select
End Sub
====================================================
Private Sub Report_NoData(Cancel As Integer)
Cancel = True
End Sub
====================================================
get it to work, I have tripple checked for spelling errors....
I use Access XP
Leif Hole, Norway
Here is what I use, from Joe Fallon:
This is a good way to handle the no data event for a report.
Note that the Print Preview button has to trap error 2501 when the code sets
Cancel=True.
====================================================
Private Sub Print_Preview_Click()
On Error GoTo Err_Print_Preview_Click
Dim DocName As String
DocName = [Forms]![Report Menu]![RptList]
DoCmd.OpenReport DocName, acViewPreview
Exit_Print_Preview_Click:
Exit Sub
Err_Print_Preview_Click:
Select Case Err.Number
Case 2501
MsgBox ("There is no data for this report.")
Case Else
MsgBox ("Error # " & Str(Err.Number) & " was generated by " &
Err.Source & Chr(13) & Err.Description)
Resume Exit_Print_Preview_Click
End Select
End Sub
====================================================
Private Sub Report_NoData(Cancel As Integer)
Cancel = True
End Sub
====================================================