LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Binding data to a ListBox without using cells

Hi Group,

I want to populate a ListBox with values returned from a query. I want the
user to see one list of text but when the user selects a value from the drop
down an ID is used instead. For example:
1, red
2, orange
3, green

The user sees red, orange and green. When they select orange the VBA behind
the scenes uses 2. Seems simple enough (and it probably is). I did some
searching online and I found one answer that discusses the DataSet object but
that was in the context of .NET, I don't know if I can even use anything
similar in Excel / VBA. I've been looking at this on and off for a couple of
days now and I'm
no closer to an answer. At one point I thought it was possible to populate
the ListBox manually as I populated it with values but that didn't seem to
work. I only want to have a ListBox that shows human readable values whilst
using reference IDs in the background. I want to do this without having to
write the values to a sheet somewhere. There is no reason for the sheet to
be poluted with data that is only used internally. I'm positive there must
be a way to do this but I can't find it. Even if the DataSet approach is the
correct way to do I don't know which module needs to be referenced to get
access to this object.

I know one approach _could_ be to populate an array at the same time as a
the ListBox. The array and the ListBox would use the same indexing so when
the user selects orange which is in position 2 of the ListBox (index=1), I
could then query the array(1) to get the ID that I want. e.g.

ListBox
0, red (index, value)
1, orange
2, green

Array
0,1 (index, ID)
1,2
2, 3

I will do that if I have to but I am hoping there is a cleaner method. Just
think of the manual maintenance should the ListBox values change (and in my
application they do).

Cheers, Max
 
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
Binding Pictures to Cells Dane Excel Discussion (Misc queries) 0 March 21st 05 01:40 AM
Late Binding examples of binding excel application HeatherO Excel Programming 13 March 17th 05 08:19 AM
XML Data Binding José Pérez Hernández Excel Programming 0 April 11th 04 08:19 PM
EARLY binding or LATE binding ? jason Excel Programming 6 February 26th 04 04:57 PM
Putting Listbox data in cells Todd Huttenstine[_2_] Excel Programming 2 November 23rd 03 12:56 AM


All times are GMT +1. The time now is 05:09 PM.

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

About Us

"It's about Microsoft Excel"