need to display message box

mitchem1

Registered User.
Local time
Yesterday, 21:27
Joined
Feb 21, 2002
Messages
153
The record source for my form is a query with the following criteria:
Like [Enter Contract Number]&"*"
It works well except for when a user enters something off the wall. Then the form enters completely blank, nothing at all is displayed, including fields.
How would I go about displaying a message box when the entered criteria doesn't match at all?
Thank you.
 
You cannot with a simple input box that is provided by a query. Build a custom form just to input that data and then you can validate the input before the query is run - or even use a combo so that only valid contract numbers can be chosen. Then reference this control in the query.
 
I suggest that you test if there are any records in the forms data source using the forms
OnOpen event. Close the form if there are no records. Try this...
Code:
Private Sub Form_Open(Cancel As Integer)
        If Me.RecordsetClone.RecordCount = 0 Then
                DoCmd.Close acForm, Me.Name
                MsgBox "There are zero records in the data source!", vbInformation, "No Records Found"
        End If
End Sub
HTH
 

Users who are viewing this thread

Back
Top Bottom