Results 1 to 15 of 15
  1. #1
    Join Date
    Jan 2003
    Posts
    24

    Unanswered: Multi-Column Combo Box

    Is there an easy way to show multi-columns in a combo box?

    I can see the multi-columns from the drop down, but when it shows the data, it only shows one column.

    I have used SQL to join two columns, but the formatting is not satisfactory, i.e.

    Smith, Jim - New York
    Johnson, Anthony - Philadelphia
    Doe, Joe - Kansas

    I need the data to appear equally spaced, even a bracket (|) separating the values is fine too, i.e.

    Smith, Jim | New York
    Johnson, Anthony | Philadelphia
    Doe, Joe | Kansas

    This is just an example (I know the locations are not lined up). Any help would be great

  2. #2
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168

    multi columns

    Unfortunately, it's not possible to show more than one column in a droo-down. You can show (as you said) 2 columns worth in one column (by trimming) but it doesn't look to hot (as you said).

    What you can do; is make a list box visible to show the selected record. You could even put the list box over the drop down.

    You could just use a list box in the first place?

    I personally prefer list boxes. Unless you're adding new data they're definately the control of choice. (actually I'd probably still use one and find some other way of inputting the data (i.e. not use 'not in list'))

    Now I'll stop rambling.

    Hope I've helped.

    john
    J.

  3. #3
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: Multi-Column Combo Box

    Originally posted by lunch36
    Is there an easy way to show multi-columns in a combo box?

    I can see the multi-columns from the drop down, but when it shows the data, it only shows one column.

    I have used SQL to join two columns, but the formatting is not satisfactory, i.e.

    Smith, Jim - New York
    Johnson, Anthony - Philadelphia
    Doe, Joe - Kansas

    I need the data to appear equally spaced, even a bracket (|) separating the values is fine too, i.e.

    Smith, Jim | New York
    Johnson, Anthony | Philadelphia
    Doe, Joe | Kansas

    This is just an example (I know the locations are not lined up). Any help would be great
    The query that you use in connection with the combo is whats going to controle the fields that are displayed. You can show multi columns in a drop down, but only one can be bound meaning only one can be used as a filter. Add the extra columns you need in the query that displays the data and you will get the effect that you want.
    Jim

  4. #4
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168

    Drop-down

    I disagree, Once the combo-box has lost the focus you can only show one field. Am I talking Sh$t?

  5. #5
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: Drop-down

    Originally posted by johncameron
    I disagree, Once the combo-box has lost the focus you can only show one field. Am I talking Sh$t?
    Ok now i see what you mean....and you are right once you have made your selection the combo box only shows you the bound column. I dont know a way around that.
    Jim

  6. #6
    Join Date
    Jan 2003
    Posts
    24
    Are there any formatting options in SQL that allow for something to be spaced maybe two TAB spaces away from some text, that would mimic what I need?

  7. #7
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by lunch36
    Are there any formatting options in SQL that allow for something to be spaced maybe two TAB spaces away from some text, that would mimic what I need?
    You can format the text like
    select
    fieldname + ' ' + fieldname combo_text
    from table

    but if you want to be able to use that combo to select data from a table the data has to be in the same format

    Jim

  8. #8
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168

    formatting it.

    'Say you want the name part to be 50 wide:

    Dim IntStringLength as integer
    Dim IntSpaceAmount as integer
    Dim StrSpaces as string

    'nameofperson is the field name of the persons name
    IntStringLength = 50-(len(nameofperson) + 2)
    'add 2 for space and comma:

    'Make the Spaces:

    For IntSpaceAmount = 1 to IntStringLength
    StrSpaces = StrSpaces + " "
    next StrSpaces

    'Put the spaces on:

    NameOfPerson = trim$([nameofperson] & strspaces)
    'Now all fields will be 50 chrs long (I think)

    -------------
    Now change the RecordSource of the ComboBox in code with the above.
    Do you see what I'm getting at?

    John

  9. #9
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: formatting it.

    Originally posted by johncameron
    'Say you want the name part to be 50 wide:

    Dim IntStringLength as integer
    Dim IntSpaceAmount as integer
    Dim StrSpaces as string

    'nameofperson is the field name of the persons name
    IntStringLength = 50-(len(nameofperson) + 2)
    'add 2 for space and comma:

    'Make the Spaces:

    For IntSpaceAmount = 1 to IntStringLength
    StrSpaces = StrSpaces + " "
    next StrSpaces

    'Put the spaces on:

    NameOfPerson = trim$([nameofperson] & strspaces)
    'Now all fields will be 50 chrs long (I think)

    -------------
    Now change the RecordSource of the ComboBox in code with the above.
    Do you see what I'm getting at?

    John

    I understand what you are saying, but wil this effect how the combo interacts with the data?
    Jim

  10. #10
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168
    If you use the OnEnter Event to put the data back how it is in the query/table. And use the AfterUpdate Event to put the Recordsource SQL into the format suggested above it should be OK.

    It is overcomplicated though. I still maintain that a ListBox would be a far better idea.

    John

    P.s. Jim, thats a fine Scottish name.

  11. #11
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by johncameron
    If you use the OnEnter Event to put the data back how it is in the query/table. And use the AfterUpdate Event to put the Recordsource SQL into the format suggested above it should be OK.

    It is overcomplicated though. I still maintain that a ListBox would be a far better idea.

    John

    P.s. Jim, thats a fine Scottish name.
    I agree with you John that is teriably complicated....If you think a list box is better maybe you should elaberate as to why.

    Jim

    P.S. Thanx Id love to visit Scotland

  12. #12
    Join Date
    Jan 2003
    Posts
    24
    This would be great to use, unfortunately I must use continuous forms for the combo boxes because there is a many to many relationship. There can be two choices which makes things more complicated.

  13. #13
    Join Date
    Jan 2003
    Posts
    46
    Can you place text boxes (one for each unbound column) adjacent to the combo box and then just push in the data from the combo box on its AfterUpdate event? Actually you can, but will it work for you?

    Me.yourTextBox = Me.YourComboBox.column(1)

    The user can view the info and the form in continuous view won't be a factor.

    Cheers, Bill

  14. #14
    Join Date
    Jan 2004
    Location
    Houston, TX
    Posts
    29
    How did you sole this problem, I am having the same difficulty?

    Thanks,

    Mr. Research

    Originally posted by lunch36
    This would be great to use, unfortunately I must use continuous forms for the combo boxes because there is a many to many relationship. There can be two choices which makes things more complicated.

  15. #15
    Join Date
    Jan 2003
    Posts
    24
    Never got it lined up...just dealt with the unequal spacing.

Posting Permissions

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