detecting empty recordset on form open

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

Guest

I am trying to create a form, frmProcessSalePayments, based on a table of
sales, tblSales. tblSales has a Yes/No field called PaymentRecd. The form
is based on SQL that selects table fields & filters on PaymentRecd=False.
The object is to use this form when a payment is received to update the
table. It works fine, except when there are no records in the table where
PaymentRecd=false (I used to test software, so I always try to plan for the
worst case). I have tried using If IsNull(Me.Recordset) and
IsEmpty(Me.Recordset) to trap this situation and display a MsgBox & close the
form in the OnLoad, OnOpen & OnCurrent events of the form. All I get is a
totally blank form. Any help would be greatly appreciated.

Thanks - Garry Gross
 
Test the RecordCount of the form's RecordsetClone in its Open event
procedure:

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
MsgBox "No records"
End If
End Sub
 
Thanks, I thought I had to use RecordCount somehow, but it did not show up
as an option in the pop-up, and when I entered Me.recordset. no popup
appeared after the dot - (nor did it for Me.RecordsetClone.). I'm probably
getting lazy because most of the time the pop-up help in VBE is really great.

Thanks again for your help -- Garry
 
Yes, the Intellisense used to show up these properties back when life was
simple in the Access 97 days.

Microsoft complicated it in A2000 by adding native support for ADO
recordsets as well as DAO, so it now does not know at design time what kind
of recordset the form is dealing with, and therefore doesn't know what
properties to offer.
 
Back
Top