Walshie1987
Technical User
- Oct 5, 2006
- 100
I have a search box (txtSearch) and a button (cmdSearch) when i enter text in txtSearch and click cmdSearch, the following code runs and filters my data to the criteria in txtSearch:
Me.Filter = ""
txtSearch.SetFocus
If Len(txtSearch.Text) = 0 Then Exit Sub
Dim strSearch As String
strSearch = "Like '*" & Me.txtSearch.Value & "*' "
Me.Filter = "tblUsers.LastName " & strSearch
Me.FilterOn = True
That is simple enough, but now, i want a message box to appear if no records match the criteria saying "No record found, add new record?" with the option of Yes nd No, I know how to make messages boxes, Yes No buttons and case select etc. But just not sure of the code i need to activate the box in the first place, any ideas?
I've had a play around with IF function but can't figyre it out.
No doubt someone out there can help.
Thanks alot
Chris
Me.Filter = ""
txtSearch.SetFocus
If Len(txtSearch.Text) = 0 Then Exit Sub
Dim strSearch As String
strSearch = "Like '*" & Me.txtSearch.Value & "*' "
Me.Filter = "tblUsers.LastName " & strSearch
Me.FilterOn = True
That is simple enough, but now, i want a message box to appear if no records match the criteria saying "No record found, add new record?" with the option of Yes nd No, I know how to make messages boxes, Yes No buttons and case select etc. But just not sure of the code i need to activate the box in the first place, any ideas?
I've had a play around with IF function but can't figyre it out.
No doubt someone out there can help.
Thanks alot
Chris