How to create "No record found" message

pcca

Registered User.
Local time
Yesterday, 17:28
Joined
May 29, 2008
Messages
14
I created a query to find records by patient's last name. If one isn't found, the blank form comes up. How can I create it so that if there is no such record, the user gets a message box with that message rather than the blank form?
 
Post what you are doing to locate the patient's name.
 
No Record found message

I created a select query where the user is asked for the patient's last name.
 
run it through the recordset.. see if it is null, if it is null display a message box saying no records.
 
No Record found message

Sorry Kidrobot - I don't understand at all. I'm new to Access.
 
Sorry Kidrobot - I don't understand at all. I'm new to Access.
Are you just using DoCmd.OpenQuery? If so then use a DCount() or DLookup() function first to see if you will get any records in your query.
 
No Record found message

I'm using a form to run the query. So the event for the button on the switchboard is as follows:

Private Sub Command9_Click()
On Error GoTo Err_Command9_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Find a Client Record"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command9_Click:
Exit Sub

Err_Command9_Click:
MsgBox Err.Description
Resume Exit_Command9_Click

End Sub
 
You can either use one of the Domain functions before opening the next form as I suggested earlier or as KidRobot suggested check the RecordCount in the OpenEvent of the next form and display a message and cancel the open if there are no records.
 
I just remembered that you are using a parameter query to ask for the name. DON'T! Put a TextBox on this form to enter the name.
 

Users who are viewing this thread

Back
Top Bottom