Christine Pearc
Christine
- Local time
- Today, 21:42
- Joined
- May 13, 2004
- Messages
- 111
The main part of my form has fields for selecting multiple search criteria. The subform shows the results of the search. (Based on Dave Eyley’s MultiCriteriaSearch demo from here.)
Me.Searchstr = Searchstr
Me.Respond_Search_subfrm.Form.Filter = Searchstr
Me.Respond_Search_subfrm.Form.FilterOn = True
It works great (thanks to Dave for sharing his demo). However, if the filter on the underlying query produces no results, I want to display a message to the user. The main form and the subform have the same query as the record source. I've looked all over this forum and the web for answers and found the following 2 snippets which looked like they would do the trick. I’ve tried them in the main form (immediately after the commands shown above) and in all sorts of places in the Main form and in the subform, but the code isn't being "hit" (no msg box).
Dim iCount As Integer
iCount = DCount("*", "qryRespondSearch")
If iCount = 0 Then
MsgBox "No records found matching the search criteria"
End If
---OR---
If RecordsetClone.RecordCount = 0 Then
MsgBox "No records found matching the search criteria"
End If
Could someone advise what I’m doing wrong, where to put either of the above bits?
Me.Searchstr = Searchstr
Me.Respond_Search_subfrm.Form.Filter = Searchstr
Me.Respond_Search_subfrm.Form.FilterOn = True
It works great (thanks to Dave for sharing his demo). However, if the filter on the underlying query produces no results, I want to display a message to the user. The main form and the subform have the same query as the record source. I've looked all over this forum and the web for answers and found the following 2 snippets which looked like they would do the trick. I’ve tried them in the main form (immediately after the commands shown above) and in all sorts of places in the Main form and in the subform, but the code isn't being "hit" (no msg box).
Dim iCount As Integer
iCount = DCount("*", "qryRespondSearch")
If iCount = 0 Then
MsgBox "No records found matching the search criteria"
End If
---OR---
If RecordsetClone.RecordCount = 0 Then
MsgBox "No records found matching the search criteria"
End If
Could someone advise what I’m doing wrong, where to put either of the above bits?