Message when No Data

  • Thread starter Thread starter Kitty
  • Start date Start date
K

Kitty

I have an option group with a bunch of radio buttons. The
buttons correspond to different options for extracting
records - if the user clicks the delinquent account radio
button, the next form is populated with all accounts that
are delinquent.

Sometimes, there aren't any. In that case, a blank form
appears with no indication no data meets whatever criteria
they selected from the option group.

Is there something, similar to the On No Data Report
event, where I can pop up a message box telling them there
are no accounts? While most users know a blank form means
there aren't any, occaisionally the form is blank because
of a problem. I'd like them - and me - to know the
difference.

Any suggestions will be appreciated.

Thanks!

Kitty
 
One way to handle this is first to open the data source of the
prospective Form as a freestanding Recordset and check its
..RecordCount Property. If this is non-zero, go ahead and open the
Form; otherwise, just give a sensible error message.

Forms don't have a NoData event, presumably because this is considered
to be a normal state for a Form (the first time you open any data
entry form, it will usually have no data in its Recordset; OTOH, you
generally won't want to open a Report if it has no data in its
Recordset).

I have an option group with a bunch of radio buttons. The
buttons correspond to different options for extracting
records - if the user clicks the delinquent account radio
button, the next form is populated with all accounts that
are delinquent.

Sometimes, there aren't any. In that case, a blank form
appears with no indication no data meets whatever criteria
they selected from the option group.

Is there something, similar to the On No Data Report
event, where I can pop up a message box telling them there
are no accounts? While most users know a blank form means
there aren't any, occaisionally the form is blank because
of a problem. I'd like them - and me - to know the
difference.

Any suggestions will be appreciated.

Thanks!

Kitty


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Since the Form's Recordset is available in the Form_Open Event, you can use
this Event to check the RecordCount. If RecordCount = 0, you can post a
MsgBox on screen and then Set the Cancel argument (of the Open Event) to
True to cancel the opening / loading of the Form.
 
If you do it this way, do you not also have to handle the Cancel as an
Error (e.g. by covering the Form open with On Error Resume Next) in
the calling Code?


Since the Form's Recordset is available in the Form_Open Event, you can use
this Event to check the RecordCount. If RecordCount = 0, you can post a
MsgBox on screen and then Set the Cancel argument (of the Open Event) to
True to cancel the opening / loading of the Form.


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Thanks. I did something similar to this, and it works
(looked at the recordset).

Re: Peter's comment about canceling causing an error, it
hasn't in my testing. I do capture that error in opening
reports that have no data.

Kitty
 
Back
Top