Wrox Programmer Forums
|
BOOK: Beginning Access VBA
This is the forum to discuss the Wrox book Beginning Access 2002 VBA by Robert Smith, Dave Sussman, Ian Blackburn, John Colby, Mark Horner, Martin Reid, Paul Turley, Helmut Watson; ISBN: 9780764544026
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Access VBA 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 September 12th, 2004, 09:26 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to populate Send a message via Yahoo to populate
Default How to get index value in combo box

Hi All,

I want to do a simple things in VB. Just populate one combo box where empID, and empName will store, and click on any selected list the empID will catch up.

To make it short I used dummy code, here it is below:

====================CODE=========================
Private Sub Form_Load()
    Dim iLoop As Long

    iLoop = 1
    For iLoop = 1 To 2
        If iLoop = 1 Then
            Form1.Combo1.ItemData(iLoop) = iLoop
            Form1.Combo1.AddItem ("Account")
        Else
            Form1.Combo1.ItemData(iLoop) = iLoop
            Form1.Combo1.AddItem ("Sales")
        End If
    Next
End Sub
=================================================

But it shows error, and do not able to get empID.

Any idea.:(

Thanks a lot.

Populate

Thanks!
Populate
 
Old June 1st, 2005, 06:22 AM
Authorized User
 
Join Date: Oct 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
There is an error in your code. Just change the code as follows and it will work.
-------------------------------------
Private Sub Form_Load()
    Dim iLoop As Long

    iLoop = 1
    For iLoop = 1 To 2
        If iLoop = 1 Then
            Form1.Combo1.AddItem "Account", iLoop
            Form1.Combo1.ItemData(iLoop) = iLoop

        Else
            Form1.Combo1.AddItem "Sales", iLoop
            Form1.Combo1.ItemData(iLoop) = iLoop
        End If
    Next
End Sub


Software proffesional from Bangalore,INDIA





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
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM





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