Getting a form to realize it has no data

daninthemix

Registered User.
Local time
Today, 12:41
Joined
Nov 25, 2005
Messages
41
I have a form tied to a query, but I want some code in the Load event that checks whether there's actually any data in the form (i.e. has the query returned matches?).

Is this easy?
 
Searching the forum is a great way to discover and learn the answers to your Access programming questions.

As a perfect example... If you had searched the forum then you would have found a few variations of this code which will close the form if the record source contains no records. Put it in the forms OnOpen event.

Code:
Private Sub Form_Open(Cancel As Integer)
    
    If Me.RecordsetClone.RecordCount = 0 Then
        MsgBox "There are zero records in the data source!", vbInformation, "No Records Found"
        DoCmd.Close acForm, Me.name
    End If
    
End Sub
 
THanks. What do I need at the end of the above to kick the user back into the previous form?

And I did search for that, but found nathing :D
 

Users who are viewing this thread

Back
Top Bottom