Search second column of Combo Box

Joshann

Registered User.
Local time
Today, 12:11
Joined
Mar 22, 2002
Messages
142
I have a form with a combo box on it. The combo is bound to the first column which is FacilityID. The combo displays the second column which is FacilityName. I am creating a search form, and I want the user to be able to search on FacilityName. I've looked around here and found where someone suggested creating a text box whose control source is the second column of the combo box, as in =FacilityID.Column(1). I did this and created a field called txtFacility, and it displays the data correctly. The problem is that I can't figure out how to perform a find from the search form. I keep getting an error message saying that "The Microsoft Jet database engine does not recognize txtFacility as a valid field name or expression."

Here's the code that's giving me problems. It is in the search button of the search form where frmFacilities is the form I'm trying to search:

Forms!frmFacilities.Form.Recordset.FindFirst "[txtFacility] = '" & me.txtSearchName & "'"

Can anyone help with this?
 
Thanks! This isn't exactly what I was looking for, but I'll give it a try.
 
And to explain why it wasn't working with the other text box -

The text box was not bound. It wasn't bound to a field, only displaying the data that was within the combo box. So, you can't search a recordset for something that isn't actually there. If the text box was indeed bound to a field that contained the information, then it could search through the recordset using the bound field that was assigned to the text box.
 

Users who are viewing this thread

Back
Top Bottom