p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Beginning VB 6 (http://p2p.wrox.com/forumdisplay.php?f=75)
-   -   Combo Box and Text Box (http://p2p.wrox.com/showthread.php?t=20943)

Rudner November 7th, 2004 09:03 PM

Combo Box and Text Box
 
Hi friends,

I used a combo box to populate the data from my table and I did it. My code goes like this. This code is written on the form load.

    rsCategory.MoveFirst
    Do Until rsCategory.EOF
        Combo1.AddItem rsCategory.Fields("CATEGORYNAME").Value
        rsCategory.MoveNext
    Loop

My problem is this. If I click the CATEGORYNAME in the combo box, I want the CATEGORYID will be written in the Text6.Text.

Ex: CATEGORYID CATEGORYNAME
      1 Analgesic
      2 Antipyritec

Hope u get my point.

Thank u

Rudner

'Text6.Text = rsCategory.Fields("CATEGORYID").Value



marcostraf November 8th, 2004 04:48 PM

Use the ItemData property:

Combo1.AddItem rsCategory.Fields("CATEGORYNAME").Value
Combo1.ItemData = Combo1.ItemData(Combo1.NewIndex) = rsCategory.Fields("CATEGORYID").Value


Marco


All times are GMT -4. The time now is 03:40 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.