Consulting

Results 1 to 5 of 5

Thread: problem with combobox

  1. #1

    problem with combobox

    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:

    [vba]
    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
    [/vba]


    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!
    Last edited by choubix; 07-16-2008 at 08:36 PM.

  2. #2
    actually: got problem with the listindex... seems it triggers errors in my code (and since I am no prob with forms...)

  3. #3
    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
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  4. #4
    thanks!

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

    thanks!

  5. #5
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    Quote Originally Posted by choubix
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •