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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help Newbie

Status
Not open for further replies.
Mar 22, 2002
29
US
I have built a form with a combo box, when the combo box is updated, I want to populate the corresponding fields in the form with data correlating to the value in the combo box.

TIA
 
Hi

Do you mean values which are part of the combo box query, in which case you use the .column() property of the combo box (column numbers begin a zero)

Or do you mean, look a record in the bound form, in which case there is a wizard to do this in A2K and after, but you need something like

Me.RecordsetClone.FindFirst "MyField = '" & cboMyCombo & "'"
Me.BookMark = Me.RecordsetClone.Bookmark

You do not need the ' if the look up field is numeric Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
What I want are values that are in the corresponding table. I want to change the value in the combo box, then populuate the form with values from the table that correspond to the record chosen from the combo box
 
Hi

OK so it is the:

Or do you mean, look a record in the bound form, in which case there is a wizard to do this in A2K and after, but you need something like

Me.RecordsetClone.FindFirst "MyField = '" & cboMyCombo & "'"
Me.BookMark = Me.RecordsetClone.Bookmark

bit you want in the after update eevnt of the combo, using your own names of course Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Sounds like you want to do a query (search) based on the contents you select in a combo box.

Create a combo box which is Unbound and enter this code under the After Update property:

Private Sub combo1_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PN] = '" & Me![combo1] & "' "
Me.Bookmark = rs.Bookmark
End Sub


This will then call up the record(s) which have a field that matches the contents of the selection in the combo box (assuming the PN field, for instance, is in that table, and the form which contains this combo box is attached to the table). Newposter
"Good judgment comes from experience. Experience comes from bad judgment."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top