PDA

View Full Version : problem with combobox



choubix
07-16-2008, 07:56 PM
hello,

I have a combobox that where the user can select Equity/Bonds/Alt Invt
Is it possible, isntead of returning these values to return 1 for Equity, 2 for Bonds and 3 for Alt Invt when the user makes a choice?

I post my code here:


For i = 1 To 6
'Security Type
bfSectype = "Sectype" & CStr(i)
With Me.Controls(bfSectype)
.AddItem "Alt Inv"
.AddItem "Equity"
.AddItem "Bond"
End With

'Zone
bfZone = "Zone" & CStr(i)
With Me.Controls(bfZone)
.AddItem "Asia"
.AddItem "Emerging Mkts"
.AddItem "Europe"
.AddItem "Japan"
.AddItem "US & World"
End With

Next i



on a separate issue: is there a way to prevent the user from NOT using the values that are part of the list? (right now, the user can override the dropdown list and write wathever he wants)

thanks!

choubix
07-16-2008, 08:31 PM
actually: got problem with the listindex... seems it triggers errors in my code (and since I am no prob with forms...)

JimmyTheHand
07-16-2008, 11:45 PM
Is it possible, isntead of returning these values to return 1 for Equity, 2 for Bonds and 3 for Alt Invt when the user makes a choice?
You need to
Set the ColumnCount property of Listbox/Combobox control to 2
Fill the 2nd column with the numbers corresponding to Equity, Bond, etc.
Set the BoundColumn property to the index of that column you need the values from. In present case you want the numbers, so set the BoundColumn to 2, as it is column #2 that contains the numbers.
You can also hide any column from the user (e.g. hide the column of numbers and display only the string values) by properly setting the ColumnWidths property.
is there a way to prevent the user from NOT using the values that are part of the list? (right now, the user can override the dropdown list and write wathever he wants)
I don't really understand, but my guess is that you need to set MatchRequired = True


actually: got problem with the listindex... seems it triggers errors in my code
I'm sure we can fix it...

Jimmy

choubix
07-17-2008, 12:46 AM
thanks!

matchrequired worked fine
trying your first solution now! (I thought the listindex was the way to go, apparently i was wrong)

thanks!

Cosmo
07-17-2008, 06:05 AM
hello,

on a separate issue: is there a way to prevent the user from NOT using the values that are part of the list? (right now, the user can override the dropdown list and write wathever he wants)

thanks!
Change the Style property from DropDownCombo to DropDownList