Combo box (Forms 2.0 Object Library)
I'm using a combo box (Microsoft Forms 2.0 Object Library) that has the property of being able to Match Entry by the First Letter. This combo object doesn't support the property of .ItemData or .NewIndex.
Using this combo box I want to save the index to the selected item. Can anyone help me?
Thank-u,
Donna
Re: Combo box (Forms 2.0 Object Library)
Are you doing this in VB6 or VBA?
Re: Combo box (Forms 2.0 Object Library)
Just store the index in a public variable of the form on the change event
Code:
Public MyIndex as Long
Private Sub MyCombo_Change()
MyIndex = MyCombo.ListIndex
End Sub
Re: Combo box (Forms 2.0 Object Library)
Quote:
Originally Posted by bushmobile
Are you doing this in VB6 or VBA?
Basically you can add a class where you have each item and its index and if you whish, also some other data too.
But isn't Forms2 basically for VBA ? As I remember, when used in VB in compiled programs in a programs setup, I got troubles to distribute the code to other machines.
Re: Combo box (Forms 2.0 Object Library)
It's part of Office, so you can't distribute it. Use the VB6 control instead.
Re: Combo box (Forms 2.0 Object Library)
I'm using VB6 and I want to store the index for each item in the list. For other combo boxes I use:
With frmNice
While Not rs.EOF
.cboStatus.AddItem rs!Description
.cboStatus.ItemData(.cboStatus.NewIndex) = rs!Key
rs.MoveNext
Wend
End With
I added this code instead, but am having trouble extracting the index to the selected item.
iindex = 0
With frmNice
While Not rs.EOF
.cboStatus.AddItem rs!Description
.cboStatus.List(iindex,1) = rs!Key
iindex = iindex + 1
rs.MoveNext
Wend
End With
I tend to make things harder than they really are! thanx again.
Re: Combo box (Forms 2.0 Object Library)
There is no array. You have to use the ItemData(x) field.
Code:
For x = 0 To 5
List1.AddItem Chr$(34) & x & Chr$(34)
List1.ItemData(x) = 0
Next x
Re: Combo box (Forms 2.0 Object Library)
The combo box from Forms 2.0 Object Library, does not support that property.
Re: Combo box (Forms 2.0 Object Library)
Why don't you use the Windows Combo instead? Otherwise, create an array for the key. Use the same index as the combobox.
I often load fields into array fieldnames, so I don't have to get them from the db more than once.
Re: Combo box (Forms 2.0 Object Library)
Quote:
Originally Posted by donna_H
I'm using VB6 and I want to store the index for each item in the list. ...
I'm again coming back to the point you cannot distribute a VB6 program which uses form2 controls. I kne that the hanling of the forms2 combo is near to an autocomplete combobox, but it has other problems as you see. Or do you need the program only for your own usage ? Or would you distribute it only together with the office package. In this case you would need to tell people to first install office and then installing your program. But I'm not sure if in new office versions there are still form2 controls.
Re: Combo box (Forms 2.0 Object Library)
It will NOT install on other machines, and the program will only run if the identical version of Word is running. It is ILLEGAL to distribute some controls that other apps use. Use the VB6 controls for free!
Re: Combo box (Forms 2.0 Object Library)
Quote:
Originally Posted by dglienna
It will NOT install on other machines, and the program will only run if the identical version of Word is running. It is ILLEGAL to distribute some controls that other apps use. Use the VB6 controls for free!
While you can't distribute Forms 2.0, it doesn't require Office, and it doesn't mean your distributed app can't use it.
Quote:
Originally Posted by ChaosTheEternal
There is a Component available, though, called
Forms 2.0, ..., but it is not directly distributable. See
this Microsoft article about how to distribute it (or to basically sum [the article] up, it requires end users to install, at the very least, the MS ActiveX Control Pad, or to already have a version of Office newer than 97), and where to download it.
But, I'd agree, a Forms 2.0 combo box is not the way to go. The standard VB combo box should work, even if you need something in the back end to help out with your goal, like an array (as dglienna suggested).
Re: Combo box (Forms 2.0 Object Library)
Even if redistribution isn't an issue, you shouldn't use the Forms 2.0 object library - it's unstable in the VB6 environment with a tendency for "out of memory" errors - MS advise against its use.
Re: Combo box (Forms 2.0 Object Library)
Quote:
Originally Posted by bushmobile
--- you shouldn't use the Forms 2.0 object library - it's unstable in the VB6 environment with a tendency for "out of memory" errors - MS advise against its use.
Exactly whats my experience.
If you dont have hundrtets of items to load into your combo but you need an autocomplete Combobox you can try to use the ActiveX Combo control which is designed in the thread
http://www.codeguru.com/forum/showpo...&postcount=123
Lesson 14 is the last version of the combo. If you want to look how to design such a Userdefined control, you can follow up the whole thread. :wave:
You will learn to create your own classes and collections so it would be easy for you to administrate very complex data if you need to do so.
Jonny Poet
Re: Combo box (Forms 2.0 Object Library)
Been there, done that already also. Too much grief. Heed our advice!