Results 1 to 3 of 3

Thread: combo boxes

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4

    Question

    Is it possible to have multiple columns in a combo box? Any help would be great. thanks in advance
    j Dion

  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello dionj,

    Here is a part of a source to fill a combobox with information from two fields from a database, delimitted by "|"


    Private Sub Form_Load()
    DbSetting = "f:\BB.mdb"

    Set DB = OpenDatabase(DbSetting)
    Set RS = DB.OpenRecordset("select * from YourTable")

    LenName = 0
    LenFirstName = 0
    RS.MoveFirst
    While Not RS.EOF 'searching for the longest string
    If Len(RS("Name")) > LenName Then LenName = Len(RS("Name"))
    If Len(RS("FirstName")) > LenFirstName Then LenFirstName = Len(RS("FirstName"))
    RS.MoveNext
    Wend

    RS.MoveFirst
    While Not RS.EOF
    Combo1.AddItem Left(RS("Name") + Space(LenName + 2), (LenName + 2)) & "| " & RS("FirstName") + Space(LenFirstName + 2)
    RS.MoveNext
    Wend

    Combo1.Text = Combo1.List(0)

    End Sub

    IMPORTANT: THIS WILL ONLY GOES WELL IF ALL CHARACTERS OF THE COMBO TEXTSTYLE DO HAVE THE SAME DISTANCE! (PROPORTIONAL)

    Michelle.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4
    Thanks for the idea, but I was hoping on being able to do it without having to pad the columns with spaces, and besides the informatin for the combo box is coming form a database with over 10,000 records so finding the longest and padding the other records would be inefficient
    j Dion

Posting Permissions

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



Click Here to Expand Forum to Full Width