S
spacerocket
I have read through all the posts in this forum, but still need help. My
questions are re. searching a form in my contacts database.
F_Contacts = Form which contains all contact particulars (ie. fields
CompanyName, PhoneNo1, PhoneNo2)
Contacts = table to store info entered in F_Contacts
F_Search1 = Form to search for Phone Number
F_Search2 = Form to search for Company Name
1. Based on the code below, I managed to successfully search for PhoneNo1.
How to extend the search so that it will search for both fields PhoneNo1 and
Phone2? How to SetFocus to the field that shows the match?
'----------
If Not IsNull(Me.txtSearch) Then
strWhere = "[PhoneNo1] = """ & Me.txtSearch & """"
DoCmd.OpenForm "F_Contacts", WhereCondition:=strWhere
DoCmd.Close acForm, "F_Search1"
Forms!F_Contacts!PhoneNo1.SetFocus
Else
MsgBox "Please enter Phone Number."
End If
'----------
2. How do I enhance the code above so that if there is no matches to the
specified search criteria, it displays a message "Not found"?
3. I'm planning to create a search button in form F_Contacts with a text box
that allows for searching CompanyName. I would like to allow entering of
partial search text instead of the whole company name using wildcards (*). I
would like to write the code in using a search button but don't know how.
Pls help. Thanks a lot in advance
questions are re. searching a form in my contacts database.
F_Contacts = Form which contains all contact particulars (ie. fields
CompanyName, PhoneNo1, PhoneNo2)
Contacts = table to store info entered in F_Contacts
F_Search1 = Form to search for Phone Number
F_Search2 = Form to search for Company Name
1. Based on the code below, I managed to successfully search for PhoneNo1.
How to extend the search so that it will search for both fields PhoneNo1 and
Phone2? How to SetFocus to the field that shows the match?
'----------
If Not IsNull(Me.txtSearch) Then
strWhere = "[PhoneNo1] = """ & Me.txtSearch & """"
DoCmd.OpenForm "F_Contacts", WhereCondition:=strWhere
DoCmd.Close acForm, "F_Search1"
Forms!F_Contacts!PhoneNo1.SetFocus
Else
MsgBox "Please enter Phone Number."
End If
'----------
2. How do I enhance the code above so that if there is no matches to the
specified search criteria, it displays a message "Not found"?
3. I'm planning to create a search button in form F_Contacts with a text box
that allows for searching CompanyName. I would like to allow entering of
partial search text instead of the whole company name using wildcards (*). I
would like to write the code in using a search button but don't know how.
Pls help. Thanks a lot in advance