Handling zero records situation

StampIT
StampIT used Ask the Experts™
on
In MS Access there is a main form with a sub form. They are linked by a common customer field. The issue is when the source query of the main form has no records for the particular customer chosen. An empty form results. How would I set this up so that when the main form source query has no records for a customer a message box advising the user that this customer has no records appears and then close the form ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
In the AfterUpdate event of your search box, check the recordcount of the form:

If Me.RecordsetClone.RecordCount = 0 Then
    MsgBox "Not found"
End If

Open in new window

Author

Commented:
Thanks. Worked great.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial