I have a table name Doctor ID, I want to create a form , in this form I want to enter the first name of the doctor / OR / phone number and then I will get all the details about this doctor,,
I noticed when I go to clinics they ask me about my phone number and then they search and find it, if they do not find it they ask about first name, whenever they write first name they can see a list of completed names of patients (just like in google when I write a search word I am prompted to select from a list of search keys ) I hope someone understands me...
Can someone tell me how to do this in neatly,, where i can either search by phone number of by name,
in the header of the form, add a combobox - the wizard will launch and select the option that you want it to find a record of the form - set it up by whatever lookup column is most typical i.e. telephone number....
when that's done
then make another combobox in the header, just like before - only this time set it to look up by last name (or whatever)
and repeat as necessary.
I've made forms where user wants to look up by Purchase Order, by Customer Name, even by Date of sale.... you can have more that one combobox.....
Private Sub Text_Search_AfterUpdate()
Dim rst As DAO.Recordset
Dim strCriteria As String
If InStr(Me.Text_Search.Value, "*") > 0 Then
strCriteria = "[Column1] LIKE '" & Me.Text_Search.Value & "' OR [Column2] LIKE '" & Me.Text_Search.Value & "'"
strCriteria = "[Column1] = '" & Me.Text_Search.Value & "' OR [Column2] = '" & Me.Text_Search.Value & "'"
Set rst = Me.RecordsetClone
If rst.NoMatch = True Then
MsgBox Me.Text_Search.Value & " was not found in the database.", vbInformation, "Search"
Me.Bookmark = rst.Bookmark
Set rst = Nothing
Where Text_Search is the name of the TextBox control where the wanted keyword is entered and [Column1] and [Column2] are the names of the 2 columns in which the search must be performed (first name of the doctor and phone number in your example). If a column is not defined as text, remove the single quotes "'" before and after its corresponding reference to Text_Search, e.g. if [Column1] is numeric, the first part of the expression becomes:
strCriteria = "[Column1] LIKE " & Me.Text_Search.Value & " OR ...