migv1
The first aforementioned example does exactly this.
Create an unbound combo box by clicking on the combo box tool and then pointing to a location on the form. When you place the combo box on the form, Access will invoke a wizard. As you go through the wizard, here are some selections to choose to obtain your outcome...
"How do you want your combo box to get its values?"
Select "Find a record on my form based on the value I selected in my combo box".
Next, you select the fields to include. I don't know your table design, but an example would be to select the customer name. (In this example, you do not have to choose the unique code such as the CustomerID). Remember, if you don't get what you want here, you can delete the combo box and re-create it.
On the next screen, you should see a list of values such as the customer names. Note also the check box - "Hide key column". In most cases, when you select the one field for your combo box, behind the scenes, Access will also select the primary key field, and it will hide it. An exception is if you use a CustomerCode which is also the primary key.
Done, just some tweaks left.
There are three key things I stress with combo boxes. Open the form up in design view, and make sure the property window is open. (Right click any where on the form and select the last option on the list - "property").
First, is the row source. Navigate to the data tab on the property window, and select the row source field. Click on the "..." graphic icon to the right to open up the query builder tool. One useful tweak is to sort your field, eg. customer name in ascending order, and close the query builder window. Save.
Below the row source is an important field is the bound column. This is key to tie the combo box to the form.
Second, is the formatting. Navigate to the format tab on the property window and review the Columns width. It will probably depict
0";1" . The 0" means that the first column, i.e. CustomerID, is not seen by the end user. The 1" defines the column width for the second column, i.e., customer name. You can tweak this for visibility.
Along with the column width field is the field column count (should be 2) and list width (will be 1", tweak if required).
Third, is the code. Access created visual basic code, VB, to support objective - select a specific customer record by selecting it from the combo box.
Navigate to the Event tab in the property window. You will see for the event "After Update" the description "[Event Procedure]". Select this field and then select the "..." graphical icon to the right. This will take you to the coding window. You may see something like...
Code:
Private Sub Combo41_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CustomerID] = " & Str(Me![Combo41])
Me.Bookmark = rs.Bookmark
End Sub
in Access 2000 or 2002, soemthing a little different with Access 97 but does the same thing.
What the code does is takes the information selected in the combo box and selects the first matching record. If the user starts typing in the combo box, Access will auto-complete the text. A useful alternative is to use ALT-DownArrow key to open the list of names so the end user can scroll down to the desired cusotmer. This approach is necessary if there are similar names.
There is more of course, but you have enough here I suspect.
Thanks for the star.
Richard