Link to home
Start Free TrialLog in
Avatar of Derek Brown
Derek BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Has Data

Can I find out if a form HasData before I try to open it ?

I have tried this

If Me.Forms!AppointmentsAll.HasData = -1 Then
    DoCmd.OpenForm "AppointmentsAll"
End If

It doesn't work

Derek
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Derek Brown

ASKER

Thank you!!

Derek
You could also use the Form_Open event to determine whether there are any records in the form.

Private Sub Form_Open(Cancel As Integer)

    Cancel = (Me.RecordsetClone.RecordCount = 0)
   
End Sub

However, if you use this technique, you will need to handle the error that occurs when you cancel the form_Open event.  This would have to be done in the routine that calls the form, so it is better to simply test before hand.