selectivly filtering records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that has a toggle button on it with three selections, what I
want to do is allow the user to toggle the respective button and then type in
a textbox what he is looking for. What I need the application to do is build
a combobox listing all the possible selections from the typed text.

For example, click contractors and then type in "Smi" and the combobox
should display all the contractors with the last name Smith. How would I go
about coding the form to do that?
 
I have a form that has a toggle button on it with three selections, what I
want to do is allow the user to toggle the respective button and then type in
a textbox what he is looking for. What I need the application to do is build
a combobox listing all the possible selections from the typed text.

For example, click contractors and then type in "Smi" and the combobox
should display all the contractors with the last name Smith. How would I go
about coding the form to do that?

Use the AfterUpdate event of the textbox to construct the SQL of a query, and
set the RowSource of the combo to that Query. I have no idea how your table
stores names or the information that a record pertains to a contractor so I
can't be precise, but it might be something like

Private Sub txtSearchName_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT PersonID, yada, yada FROM tablename" _
& " WHERE JobType = " & Me.optJobType _
& " AND LastName LIKE " & Me.txtSearchName & "*" _
& " ORDER BY LastName, FirstName;"
Me!cboMyCombo.RowSource = strSQL
End Sub

This could use error trapping, checking for empty textbox, checking for a
query returning no records, etc. but that's the basis.

John W. Vinson [MVP]
 
Back
Top