Why are you trying to re-invent the wheel, here? The Combobox Wizard will do this for you, in about minute or two! Here's a quick step-by-step:
If you haven't already done so, create a Form based on your Table, including all the Fields you want displayed.
Then simply:
- Add a Combobox to your Form.
- The Combobox Wizard will pop up
- Select "Find a record based on the value I selected in my combobox."
- From the Table the Form is based on, click on the Field you're searching by (a Field that is unique for each Record) to move it to the right side.
- Hit Next.
- Size the column appropriately.
- Hit Next.
- Name the Combobox something appropriate.
- Hit Finish.
Now you can drop the Combobox down and scroll down to the item to search by, or you can start to enter the item and the Combobox will "autofill" as you type. Hit <Enter> and the Record will be retrieved.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007