nodata event in forms

  • Thread starter Thread starter sheela
  • Start date Start date
S

sheela

Good Morning. Is there a method or event exists in forms,
similar to "nodata" event for reports?
I like to popup an msgbox, if there is no data exists when
a form opens.
I am opening a form with a command click event. The record
source for this form is in a parameter query.
Could some please let me know how to write code to give a
message to user saying there is no data exists in the form?
The code is simple, but I don't know how to write it.
TIA,
Sheela
 
sheela said:
Good Morning. Is there a method or event exists in forms,
similar to "nodata" event for reports?
I like to popup an msgbox, if there is no data exists when
a form opens.
I am opening a form with a command click event. The record
source for this form is in a parameter query.
Could some please let me know how to write code to give a
message to user saying there is no data exists in the form?
The code is simple, but I don't know how to write it.
TIA,
Sheela

Forms don't have a NoData event, but you can use the form's Load event
to determine whether there are any records and act accordingly:

Private Sub Form_Load()

If Me.Recordset.RecordCount = 0 Then
MsgBox "No records were found meeting your criteria!"
DoCmd.Close acForm, Me.Name, acSaveNo
End If

End Sub
 
Back
Top