Hi Tim,
Just wanted to add the thought that the near-match listbox can be an indispensible aid to preserving data integrity when searching with unbound controls. Alpha character strings (like names) are notoriously bad search criteria because they are so easy to misskey. If no exact-match record gets picked up on the first pass, that doesn't necessariily mean the customer isn't in the database. They may already be there with thier name spelled differently. Most large customer databases probably have a bunch of customers entered multiple times under a variety of (miss)spellings. Presenting the user with a near-match listbox gives them a list they can quickly scan to see if maybe they misskeyed something. Its also critical to add a few "numeric" search parameters if you can, like a phone number, or zip code for the same reasons. The near-match criteria might be something like the first three letters of the customers last name as follows:
Sub NearMatches()
Dim strSQL As String
Dim strCriteris As String
strCriteria = Trim(Left(Nz(Me![txtLastName]), 3))
If strCriteria <> "" Then
strSQL = "SELECT lastname, firstname "
strSQL = strSQL & "FROM Customers "
strSQL = strSQL & "WHERE lastname Like '" & strCriteria & "*' "
Else
strSQL = "SELECT lastname, firstname FROM Customers"
End If
Me.lstNearMatches.RowSource = strSQL
End Sub
About combo boxes: I tend to limit their use to short lists of relatively static lookup values. They become unweildy with long lists of dynamic values.
About performance: Performance is not impacted by the selection of one of your options over other. Both will run the identical query. The only question is which control will that query recieve its parameter values from: text boxes or combo boxes. The former will likely serve you better.
HTH,
Bob
|