Problem with Combo Drop Down Lists 
Author Message
 Problem with Combo Drop Down Lists

Hello,

I am sooooo frustrated!!!

All I want to do is put a combo drop down list on a form, and have it filled
from a database, but NOT using the Data Control.

I tried everything...If I use the regular drop down list, I can fill it ok,
but it doesn't support more than 1 column.  For example...I want to have a
list of clients, but I would like to somehow only show the Client Name, but
when the user selects the Client Name I would like to get the Client ID.

I have even tried the DB Combo, and that works great, however you have to
use the data control to fill it.

I can't believe this is this difficult, I used to be able to do this in
MS-Access in less than 3 minutes tops, but I've been working on this problem
for about 2-3 weeks now and I'm about ready to either throw my computer or
myself out the window!

I also do not have the money to purchase controls that have been created for
this type of purpose, I know they're out there and I wish I could just
purchase them and be on my merry way, but unfortunately I can't, I have to
rely on the controls that came with VB5.

Please help, I don't know where else to turn.

Thanks,

Kenneth W. Cronin



Wed, 02 Aug 2000 03:00:00 GMT  
 Problem with Combo Drop Down Lists

Hey, how about using the MS Flex Grid?  It came with your VB5 (or mine did,
anyway).  I had to spend a few minutes figuring it out for the first time,
but I really fell in love with this control.  Check it out!

If you need some sample code, drop me a note and I'll snip some out for you.

Good luck!

Ken

Quote:
>...
>I also do not have the money to purchase controls that have been created
for
>this type of purpose, I know they're out there and I wish I could just
>purchase them and be on my merry way, but unfortunately I can't, I have to
>rely on the controls that came with VB5.
>...



Wed, 02 Aug 2000 03:00:00 GMT  
 Problem with Combo Drop Down Lists


Fri, 19 Jun 1992 00:00:00 GMT  
 Problem with Combo Drop Down Lists


Quote:
>I am sooooo frustrated!!!

Goes with the territory doesn't it?

Quote:
>All I want to do is put a combo drop down list on a form, and have it filled
>from a database, but NOT using the Data Control.
>I tried everything...If I use the regular drop down list, I can fill it ok,
>but it doesn't support more than 1 column.  For example...I want to have a
>list of clients, but I would like to somehow only show the Client Name, but
>when the user selects the Client Name I would like to get the Client ID.

Yes! this is VERY POSSIBLE. I do it all the time. Keep in mind that
when your user selects the ClientName, you still have to know which
item in the list is selected right?  And what you want to do is to
ignore the "item" i.e. the ClientName and get back "data" associated
with that item: i.e. the ClientID

It's called: "Itemdata"  read on.....

Quote:
>I have even tried the DB Combo, and that works great, however you have to
>use the data control to fill it.

No you don't. At least you don't in VB3. I don't know about VB5,
BUT, what you're describing is actually very easy.

the drop-down combo has an additional "ItemData" field that most
people don't use. It's designed specifically for keeping a number
(usually a long integer) attached to the combo selection. And it will
do exactly what you want.

When you populate the drop-down, (using Combo1.AddItem  "Client Name")
you also add your client ID number to the Itemdata of the combo, then
when your user selects one from the list, you don't have to read the
name associated with the combo array, you just read the Itemdata.
---------------------beginning of example-----------------
ItemData and NewIndex Properties Example

The example fills a list box with employee names and fills the
ItemData array with employee numbers using NewIndex to keep the
numbers synchronized with the sorted list.  A label displays
the name and number of an item when the user makes a selection.  To
try this example, paste the code into the Declarations section of a
form that contains a list box and a label.  Set the Sorted property
for the list box to True.  Then press F5 and click the list box.

Sub Form_Load ()
        ' Fill List1 and ItemData array with
        ' corresponding items in sorted order.
        List1.AddItem "Judy Phelps"
        List1.ItemData(List1.NewIndex) = 42310
        List1.AddItem "Chien Lieu"
        List1.ItemData(List1.NewIndex) = 52855
        List1.AddItem "Mauro Sorrento"
        List1.ItemData(List1.NewIndex) = 64932
        List1.AddItem "Cynthia Bennet"
        List1.ItemData(List1.NewIndex) = 39227
End Sub

Sub List1_Click ()
        ' Append the employee number and the employee name.
        Msg = List1.ItemData(List1.ListIndex) & " "
        Msg = Msg & List1.List(List1.ListIndex)
        Label1.Caption = Msg
End Sub

-------------------end of example---------------------------
One bit of warning: NEVER use the Itemdata stuff without an error
handler.

I use them all the time to do exactly what you're describing.

Quote:
>I can't believe this is this difficult, I used to be able to do this in
>MS-Access in less than 3 minutes tops, but I've been working on this problem
>for about 2-3 weeks now and I'm about ready to either throw my computer or
>myself out the window!

Now now, Let's not do anything rash.

Quote:
>I also do not have the money to purchase controls that have been created for
>this type of purpose, I know they're out there and I wish I could just
>purchase them and be on my merry way, but unfortunately I can't, I have to
>rely on the controls that came with VB5.

Otherwise, how do you like VB5?
Quote:
>Please help, I don't know where else to turn.
>Thanks,
>Kenneth W. Cronin




Wed, 02 Aug 2000 03:00:00 GMT  
 Problem with Combo Drop Down Lists


Fri, 19 Jun 1992 00:00:00 GMT  
 Problem with Combo Drop Down Lists

Ken,

Access is a wonderful tool, and there are going to be times when you miss
it.  This is obviously one of those situations.

In a combo box and list box, you will be given a somewhat under used and
under documented property called itemdata.

You can think of your combo box as really having 3 columns column 1 is
invisible and in it is the "Index" (number of item in list, first item is
0), the second column is your data, and the 3rd column also invisible is
item data.

Item data can be used if you wish to store a numeric key to your data
element in the list.

Assume I already have a recordset built called RS

rs.movefirst

do while not rs.eof

    list1.additem rs("CustomerName")
    list1.itemdata rs("CustomerID")

    rs.movenext

loop

now when customer selects an item in the list, you can use the Itemdata
property as a pointer to your Key....!

Let me know if you need more help

Greg Jackson
PDX, OR



Wed, 02 Aug 2000 03:00:00 GMT  
 Problem with Combo Drop Down Lists

4th Column : .Tag

Per Rollvang, Norway

Quote:
>GregJ wrote ......<



Thu, 03 Aug 2000 03:00:00 GMT  
 Problem with Combo Drop Down Lists

You might be able to use the ItemData property to store the ClientID, then
refer to the ItemData for the selected index.
(I'm not sure if ItemData has to be a number or if you can use strings - I
would hope the latter)

e.g.  Add client to listbox:
Private Sub AddClient(lbox as ListBox, ClientName as string, ClientID as
long)
        lbox.AddItem ClientName
        lbox.ItemData(lbox.NewIndex) = ClientID
end sub

Reading clientID:
With lbox
    clientID=.ItemData(.ListIndex)
end With

Hope this helps,
Stuart{*filter*}son


Quote:
>Hello,

>I am sooooo frustrated!!!

>All I want to do is put a combo drop down list on a form, and have it
filled
>from a database, but NOT using the Data Control.

>I tried everything...If I use the regular drop down list, I can fill it ok,
>but it doesn't support more than 1 column.  For example...I want to have a
>list of clients, but I would like to somehow only show the Client Name, but
>when the user selects the Client Name I would like to get the Client ID.

>I have even tried the DB Combo, and that works great, however you have to
>use the data control to fill it.

>I can't believe this is this difficult, I used to be able to do this in
>MS-Access in less than 3 minutes tops, but I've been working on this
problem
>for about 2-3 weeks now and I'm about ready to either throw my computer or
>myself out the window!

>I also do not have the money to purchase controls that have been created
for
>this type of purpose, I know they're out there and I wish I could just
>purchase them and be on my merry way, but unfortunately I can't, I have to
>rely on the controls that came with VB5.

>Please help, I don't know where else to turn.

>Thanks,

>Kenneth W. Cronin




Thu, 03 Aug 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Problems with Combo Drop Down Lists

2. Drop Down List Box - Drop Down portion does not always disappear after Click event

3. Using Data Combo as Drop Down List ?

4. Drop-down combo list within DBGrid

5. After Update in VB4 drop down combo list

6. Drop-down combo list within DBGrid

7. Creating Drop down lists (non combo boxes) in VB5 Toolbar

8. Make Combo or list boxes drop down????

9. Modify the Width of the Drop Down List in a Combo Box

10. Combo box with Multiselect (drop down list with multiselect)

11. List hieght of a drop down combo

12. HELP: Combo Box Drop Down List Questin, Thanks in advance

 

 
Powered by phpBB® Forum Software