Results 1 to 3 of 3

Thread: DB lookup using a combo box

  1. #1

    Thread Starter
    Addicted Member DKasler's Avatar
    Join Date
    Jan 2005
    Location
    Brooklyn, NYC
    Posts
    177

    DB lookup using a combo box

    I saw an app thats in use her in my office that uses some sort of Combo box to look records in a DB then display the record in the appropriate controls.

    Now... the db has 1 field for the Last name, and 1 field for the First name...

    However the combo box combines the two fields like Last Name, First Name and displays them in the drop down.

    Any ideas how to accomplish that?
    -----MY SITES-----
    BayRidgeNights.Com - NYC Nightlife Forums

    Fight Communism - Rate Posts!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: DB lookup using a combo box

    VB Code:
    1. Combo1.Additem FirstName & " " & LastName

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: DB lookup using a combo box

    You would first have get all records you need from table using perhaps ADO Recordset, Connection objects. To get records you'll also need some SQL statement like:

    Select * From Employee Where Dpt = 'IT'

    You'll then loop through your recordset and add <LastName & " " & FirstName> to your combobox just like Hack demonstrated.
    After that you have two choices: either populate some UDT with the rest of info but simultaniously with combobox so indexing will be in-sync OR you'll have search recordset every time.
    If you use array of UDT then upon secting new name from combo - you'll get rest of info from your UDT and populate your textboxes.

    If you have any problem with implementing all of the above - give me a buzz.

    Good luck.

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