I have a form called Profile_Form.
In this form i have a listbox called NamePicker_Listbox
It is populated with data from a table called Profile_Table.
The listbox have 3 columns, profile_ID, FirstName, LastName
I want to add a textbox (Text142) to my profile_form
When the user types in some data in the textbox (Text142) and press a commandbutton i want to display the result in the listbox. A search so to say.... If the user types in "o" in the textbox all records with an "o" should show in the listbox.
I have searched and watched videos and think i can solve this by adding this code to a commandbuttons on click event.
Idea is that the WHERE statement is searching something LIKE the thinks typed into the texbox called Text142
But if i type something in the textbox and then press the button.
The listbox is just empty, no results.
Im thinking this is because im really only searching the first column and not all columns in the listbox.
Is this correct? If so how to fix it?
Or is there any other solution?
In this form i have a listbox called NamePicker_Listbox
It is populated with data from a table called Profile_Table.
The listbox have 3 columns, profile_ID, FirstName, LastName
I want to add a textbox (Text142) to my profile_form
When the user types in some data in the textbox (Text142) and press a commandbutton i want to display the result in the listbox. A search so to say.... If the user types in "o" in the textbox all records with an "o" should show in the listbox.
I have searched and watched videos and think i can solve this by adding this code to a commandbuttons on click event.
Code:
Dim sql As String
sql = "SELECT Profile_Table.Profile_ID, Profile_Table.FirstName, Profile_Table.LastName" _
& "FROM Profile_Table" _
& "WHERE Profile_Table.LastName LIKE '*" & Me.Text142 & "*' " _
& "ORDER BY Profile_Table.LastName;"
Me.NamePicker_Listbox.RowSource = sql
Me.NamePicker_Listbox.Requery
Idea is that the WHERE statement is searching something LIKE the thinks typed into the texbox called Text142
But if i type something in the textbox and then press the button.
The listbox is just empty, no results.
Im thinking this is because im really only searching the first column and not all columns in the listbox.
Is this correct? If so how to fix it?
Or is there any other solution?