Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    multiple colums in msocontroldropdown (2000 / 2003)

    Hi all,

    Is is possible to add more than one column to an msocontroldropdown and preferrably hide the second column but still be able to call the value within vba.

    Many thanks
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: multiple colums in msocontroldropdown (2000 / 2003)

    I don't think you can have multiple columns in a CommandBar drop down control. I faked it by padding the values out with spaces, then adding two vertical bars and the data I would have placed in the second column. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Then I use Split() to easily get at the data component of the control's Text property:

    <code>myData = Split(myControl.Text, "||")(1)</code>

    (This actually is an Outlook project, so it probably would be more confusing than helpful to show the code here.)

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: multiple colums in msocontroldropdown (2000 / 2003)

    Many thanks I think I could use the same idea to work what I'm doing very clever. The only way I thought of was to use an access table and a lookup that maps the combo values to the dta I need to use. I wasn't keen on this idea because word is already grabbing and sending data to the same access table about 6 times thoughout the process of the macro. I was worried about the lag in creating the document with so much searching through tables with more than 80'000 records on them.

    Anyway's once again thank for sharing your knowledge.

    One quick question.

    When youing split.

    What is the breakdown of how it works? Is it?
    Split(item u want 2 split, " what identifiy's the split")(????????)

    I'd just like to understand what I using then maybe I won't ask so many questions. Thanks
    Regards
    Gerbil (AKA Kevin)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: multiple colums in msocontroldropdown (2000 / 2003)

    If you type the word Split somewhere in the Visual Basic Editor and press F1, you'll get the built-in help for the Split function. Or see Split Function.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: multiple colums in msocontroldropdown (2000 / 2003)

    That was a shorthand usage combining the function yielding an array, and the desired array index, into a single line. The more typical usage is:

    <code>Dim strArray() as String
    strArray = Split(myControl.Text, "||")
    myData = strArray(1)</code>

  6. #6
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: multiple colums in msocontroldropdown (2000 / 2003)

    Thanks I think I understand now.
    Regards
    Gerbil (AKA Kevin)

  7. #7
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: multiple colums in msocontroldropdown (2000 / 2003)

    Thanks Hans,

    I keep forgetting I can press F1 to get help.!!
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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