Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default what is itemdata equivilent (if exists)

the combobox control in excel vba does not appear to support the ItemData
property. How can i accomplish the equivilent use with the combobox in excel
vba? I am feeding the combobox from a database, and need to populate both the
text value and the Primary Key ID number into the combobox from my query. How
is this accomplished in excel vba?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default what is itemdata equivilent (if exists)

Hi

Based on my research, the ItemData is used to get the data based on the
index.
e.g.
Label1.Caption = "Empoyee #" & _
CStr(Combo1.ItemData(Combo1.ListIndex))

VBA controls has different implement with the VB controls. The VBA Controls
ComboBox did not have the ItemData property.
We will find that we will add two columns into the combobox, so that when
we change the BoundColumn, the ComboBox1.Value
will change to different column.

I think you may try to run the code below.
Private Sub OptionButton1_Click()
ComboBox1.BoundColumn = 0
Label1.Caption = ComboBox1.Value
End Sub

Private Sub OptionButton2_Click()
ComboBox1.BoundColumn = 1
Label1.Caption = ComboBox1.Value
End Sub

Private Sub OptionButton3_Click()
ComboBox1.BoundColumn = 2
Label1.Caption = ComboBox1.Value
End Sub

Private Sub ComboBox1_Click()
Label1.Caption = ComboBox1.Value
End Sub

Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 2
ComboBox1.AddItem "Item 1, Column 1"
ComboBox1.List(0, 1) = "Item 1, Column 2"
ComboBox1.AddItem "Item 2, Column 1"
ComboBox1.List(1, 1) = "Item 2, Column 2"
ComboBox1.Value = "Item 1, Column 1"
OptionButton1.Caption = "List Index"
OptionButton2.Caption = "Column 1"
OptionButton3.Caption = "Column 2"
OptionButton2.Value = True
End Sub

Also if you are using ADO to access to Database, then I assme you are using
Recordset.
So we can use recordset's filter function to filter the PK, so that we now
have one record, because the PK is unique.
Now we can retrieve the columnx to get the data we want from the Recordset.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input Masks or equivilent Courtney Excel Worksheet Functions 1 January 13th 07 02:57 AM
File Exists Mike McLellan Excel Discussion (Misc queries) 2 May 4th 06 09:20 AM
keyboard equivilent of the right-click jenn Excel Worksheet Functions 2 December 22nd 05 05:57 PM
Exists? Tom Excel Programming 3 March 9th 05 10:43 AM
Combobox ItemData BananaQuaalude[_2_] Excel Programming 4 May 10th 04 05:52 PM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"