CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Posts
    20

    Data Combo populate

    I'm not sure about how easy this is, but Is there a way to populate fields of a record by selecting the info from a data combo control? For example, say the data combo is filled with company names. By selecting one of those company names all information from the company table will automatically come up on the form so that the user will not have to type the information themselves. Can this be done and how? I would appreciate any help at all.


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Data Combo populate

    Select name from the combobox and generate an SQL which will retrieve the record from the database and fill your correspondent text boxes.

    for text field
    sSQL = "select * from YourTable where YourField = '" & Combo1.Text & "'"

    for numeric field
    sSQL = "select * from YourTable where YourField = " & Val(Combo1.Text)

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Apr 2001
    Posts
    20

    Re: Data Combo populate

    Thank you very much for your help. I have another question. This company data is part of a bigger database that i need to update. I actually have four tables in the database. The main table is a Project Table which holds the primary key (project number) and other data about the project (jobsite info, billing info). The Project Contacts table holds the primary key project num (to relate it with the project table) and the contact ID. The next table is the Contact Table which holds the primary key Contact ID and all the information about the contacts (phone, mobile number, fax) and the company ID. The last table is the Company Table which holds the primary key company ID and all the company information about the contact (company address, phone, fax). Having filled in the company info from the data combo how do i update all the corresponding tables? By the way i'm using ADO controls and access 2000 as a back end. Thanks in advice for your help.


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Data Combo populate

    After filling the data you can execute SQL to update other tables

    SQL = "Insert into YourTable Values(Value1, Value1,...)"

    rate it if it helped you

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured