Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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


 
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




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





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