Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box help!!

Status
Not open for further replies.

welshspoon

Technical User
Joined
Dec 14, 2002
Messages
34
Location
GB
I have a combo box on my form. My problem is that i want to be able to select an option from the combo box and i want the form to populate the forms fields with the data relevant to that option. For example, select a name from a combo box and it then brings up that persons details.

please help me!!
 
Check out the combo box wizard that "finds a record on my form based on a value I choose from a combo box" - it's all of three lines of code and should do exactly what you want.

Requirements : form bound to a query or table.
Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
First off - your FIELDS ( which are in the underlying table ) must already be 'populated' - otherwise where will you get your data from.

What you really want to do is 'populate' the CONTROLS on the form

Have the form laid out with all the controls named as appropriate but UNBOUND

Have the ComboBox's RowSource pointing to the table where the data will come from with the combo box Bound Column as the underlying table's primary key

Then in the combo boxes AfterUpdate event

Open a Recordset on the underlying table using the Where clause of
"WHERE tblPrimeKey = " & cboBoxName

Then step through all the fields in the recordset setting
Control1 = rst!Field1
Control2 = rst!Field2
etc.. ..
etc.




Alternative:-

Have all the controls BOUND to their respective fields but then make the FORM's RecordSource = Null

Then in the comboBoxes AfterUpdate event have something like
Code:
Dim strSQL As String

strSQL = "SELECT * FROM tblName " _
         "WHERE tblPrimeKey = " & cboBoxName

Me.RecordSource = strSQL


Either option has advantages depending on what you are doing.
If you want to update info into the table easily use the 2nd option.



'ope-that-'elps
G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top