Hi
I have the following SQL associated to a field's afterupdate event.
It works well, but now as the db grows, I need to tweak it as the number of results I get is too large.
First I would like to know how to order the results so they come out alphabetically (by Last name, for example)
Then, I will create a second text field in the form where a second text string is entered(let's call it txtsearch2) that basically takes the results yielded by the SQL above and narrows them down to those that also match this second text string.
Any suggestions?
Thanks
mafhobb
I have the following SQL associated to a field's afterupdate event.
Code:
' Search Procedure
Me.lstsearch.RowSource = "Select [ContactID], [CustomerID], [FirstName], [LastName], [PostalCode], [CompanyName], Format([WorkPhone],'(###) ###-####'), Format([HomePhone],'(###) ###-####'),Format([MobilePhone],'(###) ###-####'),[EmailName]" & _
"From [Contacts]" & _
"Where [CustomerID] like '*" & Me.txtsearch & "*'" & _
"OR [FirstName] like '*" & Me.txtsearch & "*'" & _
"OR [LastName] like '*" & Me.txtsearch & "*'" & _
"OR [PostalCode] like '*" & Me.txtsearch & "*'" & _
"OR [CompanyName] like '*" & Me.txtsearch & "*'" & _
"OR [WorkPhone] like '*" & Me.txtsearch & "*'" & _
"OR [HomePhone] like '*" & Me.txtsearch & "*'" & _
"OR [MobilePhone] like '*" & Me.txtsearch & "*'" & _
"OR [EmailName] like '*" & Me.txtsearch & "*'"
Me.lstsearch.Requery
First I would like to know how to order the results so they come out alphabetically (by Last name, for example)
Then, I will create a second text field in the form where a second text string is entered(let's call it txtsearch2) that basically takes the results yielded by the SQL above and narrows them down to those that also match this second text string.
Any suggestions?
Thanks
mafhobb