F fredg Jan 9, 2005 #2 Anyway to bring up a messagebox if a report contains no info? Thanks DS Click to expand... Code the Report's OnNoData event: MsgBox "Sorry, no records to report on." Cancel = true The above will generat error 2501 if you have opened the report from an event. Trap the error in that event: On Error Goto Err_Handler DoCmd.OpenReport "ReportName", acViewPreview Exit_This_Sub: ExitSub Err_Handler: If Err = 2501 Then Else MsgBox "Error #: " & Err.Number & " " & Err.Description End If Resume Exit_This_Sub
Anyway to bring up a messagebox if a report contains no info? Thanks DS Click to expand... Code the Report's OnNoData event: MsgBox "Sorry, no records to report on." Cancel = true The above will generat error 2501 if you have opened the report from an event. Trap the error in that event: On Error Goto Err_Handler DoCmd.OpenReport "ReportName", acViewPreview Exit_This_Sub: ExitSub Err_Handler: If Err = 2501 Then Else MsgBox "Error #: " & Err.Number & " " & Err.Description End If Resume Exit_This_Sub
D DS Jan 9, 2005 #3 fredg said: Code the Report's OnNoData event: MsgBox "Sorry, no records to report on." Cancel = true The above will generat error 2501 if you have opened the report from an event. Trap the error in that event: On Error Goto Err_Handler DoCmd.OpenReport "ReportName", acViewPreview Exit_This_Sub: ExitSub Err_Handler: If Err = 2501 Then Else MsgBox "Error #: " & Err.Number & " " & Err.Description End If Resume Exit_This_Sub Click to expand... Great! Thank you, It works! DS
fredg said: Code the Report's OnNoData event: MsgBox "Sorry, no records to report on." Cancel = true The above will generat error 2501 if you have opened the report from an event. Trap the error in that event: On Error Goto Err_Handler DoCmd.OpenReport "ReportName", acViewPreview Exit_This_Sub: ExitSub Err_Handler: If Err = 2501 Then Else MsgBox "Error #: " & Err.Number & " " & Err.Description End If Resume Exit_This_Sub Click to expand... Great! Thank you, It works! DS