Checking If Recordset Returns Any Rows

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

Hi. I have a continuous form that is based on a select statement
that checks the value of a record's check box. If the check box's
value is Yes the record is displayed.
Simply put there are times when I am certain the recordset will
return no records. When no records are returned the form opens
fine but nothing at all is displayed.
I would like to check for no records and then display a MsgBox
or add an unbound label to be displayed only if there are no records.
How can I check for no records?? I considered checking the
recordset's BOF and the EOF or the Recordcount but don't know
were to start. Any help will be appreciated.

Thanks,
James
 
Hi. I have a continuous form that is based on a select statement
that checks the value of a record's check box. If the check box's
value is Yes the record is displayed.
Simply put there are times when I am certain the recordset will
return no records. When no records are returned the form opens
fine but nothing at all is displayed.
I would like to check for no records and then display a MsgBox
or add an unbound label to be displayed only if there are no records.
How can I check for no records?? I considered checking the
recordset's BOF and the EOF or the Recordcount but don't know
were to start. Any help will be appreciated.

Thanks,
James

Use the form's Open event to check the records with the
RecordsetClone.

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
'No records
MsgBox "No records to display!"
Cancel = True
End If
End Sub


- Jim
 
That'll work! Thanks, Jim.

Thanks again,
James

Jim Allensworth said:
Use the form's Open event to check the records with the
RecordsetClone.

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
'No records
MsgBox "No records to display!"
Cancel = True
End If
End Sub


- Jim
 
Back
Top