Geordie2008
Registered User.
- Local time
- Today, 07:48
- Joined
- Mar 25, 2008
- Messages
- 177
Hello's
This is a duplicate post as I couldn't work out how to move it from the "Forms" forum, apologies, but Im really stuck with this....
I have a form with 2 unbound text boxes.
First Name (txt_First_Name)
Last Name (txt_Last_Name)
I have a combo box on the same form which I would like to be filtered by the values entered into the 2 unbound boxes.
So:
First Name: M
Last Name: Jones
Should populate the combo box with:
Mark Jones
Michael Jones
etc.
I used the following on the "row source" of the comboBox properties (which works):
Code:
SELECT Tbl_MAIN_Staff_Details.ID, Tbl_MAIN_Staff_Details.Last_Name, Tbl_MAIN_Staff_Details.First_Name FROM Tbl_MAIN_Staff_Details WHERE ((Tbl_MAIN_Staff_Details.Last_Name Like forms!test!txt_Last_Name And Tbl_MAIN_Staff_Details.First_Name Like forms!test!txt_First_Name));
When I try and add in the wildcard "*", it doesn't work.....
Code:
SELECT Tbl_MAIN_Staff_Details.ID, Tbl_MAIN_Staff_Details.Last_Name, Tbl_MAIN_Staff_Details.First_Name FROM Tbl_MAIN_Staff_Details WHERE ((Tbl_MAIN_Staff_Details.Last_Name Like '" & forms!test!txt_Last_Name & "*' And Tbl_MAIN_Staff_Details.First_Name Like '" & forms!test!txt_First_Name & "*'"));
Code:
SELECT Tbl_MAIN_Staff_Details.ID, Tbl_MAIN_Staff_Details.Last_Name, Tbl_MAIN_Staff_Details.First_Name FROM Tbl_MAIN_Staff_Details WHERE ((Tbl_MAIN_Staff_Details.Last_Name Like forms!test!txt_Last_Name & “*” And Tbl_MAIN_Staff_Details.First_Name Like forms!test!txt_First_Name & “*”))
The above code gives me the follwoing error:
This expression is typed incorrectly of it is too complex to be evaluated.
Can anyone help me with this please? Or if its not possible to amend my code above to work.....Is there anyway I can do this in VBA maybe (rather than the row source)? I have the VBA to code the "like *" statement and I know it works, I just dont know how to make it populate the combo box....
Many thanks,
Mandy
This is a duplicate post as I couldn't work out how to move it from the "Forms" forum, apologies, but Im really stuck with this....
I have a form with 2 unbound text boxes.
First Name (txt_First_Name)
Last Name (txt_Last_Name)
I have a combo box on the same form which I would like to be filtered by the values entered into the 2 unbound boxes.
So:
First Name: M
Last Name: Jones
Should populate the combo box with:
Mark Jones
Michael Jones
etc.
I used the following on the "row source" of the comboBox properties (which works):
Code:
SELECT Tbl_MAIN_Staff_Details.ID, Tbl_MAIN_Staff_Details.Last_Name, Tbl_MAIN_Staff_Details.First_Name FROM Tbl_MAIN_Staff_Details WHERE ((Tbl_MAIN_Staff_Details.Last_Name Like forms!test!txt_Last_Name And Tbl_MAIN_Staff_Details.First_Name Like forms!test!txt_First_Name));
When I try and add in the wildcard "*", it doesn't work.....
Code:
SELECT Tbl_MAIN_Staff_Details.ID, Tbl_MAIN_Staff_Details.Last_Name, Tbl_MAIN_Staff_Details.First_Name FROM Tbl_MAIN_Staff_Details WHERE ((Tbl_MAIN_Staff_Details.Last_Name Like '" & forms!test!txt_Last_Name & "*' And Tbl_MAIN_Staff_Details.First_Name Like '" & forms!test!txt_First_Name & "*'"));
Code:
SELECT Tbl_MAIN_Staff_Details.ID, Tbl_MAIN_Staff_Details.Last_Name, Tbl_MAIN_Staff_Details.First_Name FROM Tbl_MAIN_Staff_Details WHERE ((Tbl_MAIN_Staff_Details.Last_Name Like forms!test!txt_Last_Name & “*” And Tbl_MAIN_Staff_Details.First_Name Like forms!test!txt_First_Name & “*”))
The above code gives me the follwoing error:
This expression is typed incorrectly of it is too complex to be evaluated.
Can anyone help me with this please? Or if its not possible to amend my code above to work.....Is there anyway I can do this in VBA maybe (rather than the row source)? I have the VBA to code the "like *" statement and I know it works, I just dont know how to make it populate the combo box....
Many thanks,
Mandy