Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 7th, 2004, 09:03 PM
Authorized User
 
Join Date: Nov 2004
Location: Caloocan, Philippines, Philippines.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


Reply With Quote
  #2 (permalink)  
Old November 8th, 2004, 04:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use the ItemData property:

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


Marco
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a text box from a combo box value dnf999 Access VBA 7 February 6th, 2012 02:24 PM
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Combo box and Text box Rudner Access VBA 4 November 16th, 2004 02:57 PM



All times are GMT -4. The time now is 12:09 AM.


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