M/T result set

B

Bill - ESAI

Hi All

Hope ya all had a great week-end.

I have a report with a record source set to a query. All works fine as long
as there are results returned by the query. On the reports "On Open" command
I have a event procedure that filters the query and I would also like to add
a popup or something a little more elegant than a report full of empty
spaces in the event of an empty result set. So, I'm wondering how you folks
generally handle empty recordsets?

Thanks

Bill
 
B

bcap

Program the NoData event e.g.

Private Sub Report_NoData(Cancel As Integer)

MsgBox "Nothing to Report"
Cancel = True

End Sub

Note that, if you used code to open the report, an error will be thrown
there - "The OpenReport action was cancelled", or something like that. You
may want to trap and discard it.
 
B

Bill - ESAI

Perfect, Thank you. One last request though, any chance you can give me an
example of capturing that OpenReport error and discarding it like you
mentioned??

Bill
 
B

bcap

Sure, I can give you a rough idea, but it kind of depends on whatever error
handling method you generally implement. I can't remember what the error
number is, but let's suppose it's 9999, you can change it when you find out
what it really is. Anyway, here goes:

Private Sub OpenMyReport()

On Error GoTo HandleError

DoCmd.OpenReport "rptSomeReport"

EndOfSub:
Exit Sub

HandleError:
If Err = 9999 Then
Resume EndOfSub
Else
Err.Raise Err
Resume EndOfSub
End If

End Sub
 
B

Bill - ESAI

I got it sorted. Thank you for your help :)

I added

If Err.Number = 2501 Then
Resume Exit_cmdPrintProjectEventLog_Click
Else

MsgBox Err.Description
Resume Exit_cmdPrintProjectEventLog_Click
End If

to my error click event

Bill

..
 
B

bcap

Snap! :)


Bill - ESAI said:
I got it sorted. Thank you for your help :)

I added

If Err.Number = 2501 Then
Resume Exit_cmdPrintProjectEventLog_Click
Else

MsgBox Err.Description
Resume Exit_cmdPrintProjectEventLog_Click
End If

to my error click event

Bill

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top