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

Report_Close event when there's no data

Status
Not open for further replies.

annie52

Technical User
Mar 13, 2009
164
0
0
US
I handle the 2501 error in the Report_NoData event but, if there is no data, I don't want this message to appear in the Report_Close event. Should I set a global variable to capture the NoData value or is there a better way?

Response = MsgBox("If you are satisfied with the report" _
& vbCrLf & "click on the [OK] button to update the" _
& vbCrLf & "underlying table with today's report date." _
& vbCrLf & "Otherwise, click on the [Cancel] button.", vbOKCancel, _
"RPP Tracking System")
If Response = vbOK Then
' run query to update the ReportDate field where it is null
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryMilTxnStatusCode-DateReported"
Else
' do nothing
End If
 
I don't want this message to appear in the Report_Close event

Huh? What message?
Just set Cancel = True.
Code:
Private Sub Report_NoData(Cancel As Integer)

    MsgBox "There is no data to print.", vbCritical
    Cancel = True

End Sub

Ni neart go cur le cheile.
 
I already did that. My problem is that after the NoData message displays, the Report_Close event occurs and runs the code I pasted above.
 
Gotcha. A public variable within the report should suffice. I always make it a habit of initializing it in the Report_Open() event as well.

Ni neart go cur le cheile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top