close form when record empty closes everything

prostheticHead

Registered User.
Local time
Tomorrow, 03:35
Joined
Dec 14, 2004
Messages
42
i just added to my forms that use Quires

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "ERROR: There are zero records in the data source!", vbInformation, "No Records Found"
DoCmd.Close acForm, Me.Name
End If

Problem is this code closes not just the would be empty form

it also close my start/Main form

as you can emagin this is more painfull then an empty form! :)
 
I think you are closing the wrong form! Instead of using the close form use cancel

Try this
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "ERROR: There are zero records in the data source!", vbInformation, "No Records Found"
Cancel = True
End If

This will Cancel the open event of the form you are opening and take you back to where you started

I love your user name
 
sweet that fixed it thanks
 

Users who are viewing this thread

Back
Top Bottom