josephbupe
Registered User.
- Local time
- Today, 21:21
- Joined
- Jan 31, 2008
- Messages
- 247
Hi,
Please, I have limited logic capability on this.
The text boxes for search criteria and the SEARCH button are on the main form while the search results are on a pop up form.
I do not want the details form to open if the provided criteria does not match with any record in the database. Instead I want the error message "Sorry, no search criteria" to pop up, but in my current state when there are no matching results/no criteria the details form still opens with some records together with the error message.
Here is the code behind the SEARCH button:
Please, I have limited logic capability on this.
The text boxes for search criteria and the SEARCH button are on the main form while the search results are on a pop up form.
I do not want the details form to open if the provided criteria does not match with any record in the database. Instead I want the error message "Sorry, no search criteria" to pop up, but in my current state when there are no matching results/no criteria the details form still opens with some records together with the error message.
Here is the code behind the SEARCH button:
Code:
Private Sub btnSearch_Click()
On Error GoTo Err_Msg
If Not IsNull(Me.Form) Then
DoCmd.OpenForm "f_search"
' Update the record source
Forms.f_search!f_search_sub.Form.RecordSource = "SELECT * FROM q_vehicles " & BuildFilter
Me.Requery
Else
Exit_btnSearch_Click:
Exit Sub
Err_Msg:
MsgBox "Sorry, no search criteria.", vbInformation, "MV Clearance"
End If
End Sub