Testing for No Data on Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to test for "No Data" before a form a is display.


Is "HasData" a solution. If so, How do I setup the code and on what form
event.
 
in message:
I need to test for "No Data" before a form a is display.


Is "HasData" a solution. If so, How do I setup the code and on what form
event.

Use the form's open event to test the recordset returned.
Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records to display at this time." _
, vbInformation, "No Records"
Cancel = True
End If
End Sub

You will of course need to trap for and ignore Error 2501
in the code routine that opens the form.
 
Thank you Jeff
Solution worked prefectly


Jeff Conrad said:
in message:


Use the form's open event to test the recordset returned.
Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records to display at this time." _
, vbInformation, "No Records"
Cancel = True
End If
End Sub

You will of course need to trap for and ignore Error 2501
in the code routine that opens the form.
 
Back
Top