The easiest way to create a combo box that is populated by the rows of a
table or query is to use the wizard. Enable the wizard in form design view
by selecting View, Toolbox, and toggling on the button with the wand and
stars. Select the Combo box icon from the Toolbox and click and drag to size
the control on the form.
The wizard will launch automatically and walk you through it. Select the
table or query, and all of the columns you want in the box. Be sure to
include the primary key; you will need it to launch your other form. Select
the default "Hide Primary Key Field (recommended)" to display the 2nd column
after the user has made a selection.
To display one of the other columns in a form textbox, use the column
property--set the ControlSource to:
=YourComboBox.Column(index)
where index is the number of the column, beginning with 0, and columns count
whether or not they are displayed.
To launch a new form, place the following code in the combo box' AfterUpdate
event procedure:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "YourFormName"
' Change YourFormName to the name of your 2nd form
' Change PKFieldName to the name of the primary key in the form's
RecordSource
' Change Control to the name of the control on the first form that has
the PK data
' This will, by default, be the first column in your combo box, so
change it to
' the name of your combo box
stLinkCriteria = "[PKFieldName]=" & Me![Control]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Hope that helps.
Sprinks
HOW DO I CREATE A SEARCH FORM???? said:
CAN SOMEBODY HELP ME CREATE A FORM THAT FIRST OF ALL, CONTAINS A LIST BOX OR
COMBO BOX THAT WILL SHOW ALL OF THE RECORDS FROM A TABLE; NOW I WANT TO HAVE
A TEXT BOX THAT WILL LOOK UP VALUES IN THAT COMBO OR LIST BOX WITHIN THE
FORM. LAST THING I WANT IS THAT WHEN I CLICK ON THE RECORD I SELECT, A FORM
WILL OPEN DISPLAYING ALL THE INFORMATION IN THAT RECORD (I HAVE ALREADY
CREATED THAT FORM). I DONT KNOW IF I EXPLAINED MYSELF RIGHT BUT PLEASE LET ME
KNOW IF I HAVE TO GIVE FURTHER EXPLANATIONS ON THIS.