Results 1 to 10 of 10

Thread: DB and Combo Box

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    OK here is my question:

    If you wanted to fill the contents of two different fields into one combo box how would you do it? Example:

    One field called email, the other one called email_address.

    Combo box called cboemail

    Could you place the email field next to the email_address in the combo box. So in other words the email field would match the name to the actual persons email address.

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    82
    Is this what you are after? Using an unbound combo box control.

    Code:
    Dim rcsTest as recordset
    Dim SQLStatement as string
    
    SQLStatement = "Select [email], [email_address] from [Table]....."
    
    Set rcsTest = YourDB.OpenRecordset(SQLStatement)
    with rcsTest
       if (not .BOF) and (not .EOF) then .MoveFirst
       Do While Not .EOF
          cboemail.additem ![email] & chr(9) & [email_address]
          .movenext
       loop
       .close
    end with
    Or have I missed the point?

    Adrian.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    That should work, I changed the names of the fields to the actual ones that I use but I get external name not defined, compile error. It is saying that it does not know what I am trying to refer to. Any suggestions?

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    It breask on:
    cboemail.AddItem ![Name] & Chr(9) & [email_addrs].

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    You have missed out ! in fornt of [email_adrs]

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Thats not or I am not getting it....

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Any more suggestions?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    OK I kind of got it but how do I have it fill on the same line as the address.

    Example it is coming up like this

    [email protected]
    Brian Hratline

    I want it to look like
    [email protected] - Brian Hartline

  9. #9
    Lively Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    82
    How about cboemail.additem ![Name] & " - " & ![email addrs]

    Adrian.

  10. #10
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    You can use Space function:

    cboemail.AddItem ![Name] & Space(5) & ![email_addrs]

    or

    cboemail.AddItem ![Name] & " " & ![email_addrs]

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