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

Populate textboxes with data determined by an item in the combo box 2

Status
Not open for further replies.

VBVines

MIS
Jun 11, 1999
98
US
I once made a form with a combo box and several text boxes on it. It was made in dao but I now I want to use ado to populate the text boxes with with items in the list of the combo box. If you were to pick an item in the list in the combo box the text boxes would be populated with other items from that row from either an access table or another type of db. I know it used itemdata and list index but I can't remember how I did it. Can anyone help?? aspvbwannab
 
Hi

when you populate your combo box make sure you assign a unique id that identifies the row the combo box item belongs to, to the Itemdata property of that listitem

In other words

Combo1.Additem (Fields("ComboText").Value
Combo1.ItemData(Combo1.NewIndex) = (Fields("UniqueID").Value

 
If your using a database then i hope your using a DBCombo box... Anyway in the MouseDown event of the DBCombo put this code and i hope i got it right....

Dim sBookmark As String
sBookmark = WhateverDBCombo1.SelectedItem
WhateverData1.Recordset.Bookmark = sBookmark

now if all the text box's on your form are tuned into the data fields ie.....Text1.datasource = Whateverdata1 and
Text1.datafield = Whateverfield then when a user selects a name from the WhateverDBCombo1 all the corresponding data will change in the text box's on the form to match the data for the name.

Hope it helps...

CuJo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top