Filling in text Box With Combo Select


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Filling in text Box With Combo Select

  1. #1
    Jason Guest

    Filling in text Box With Combo Select


    I have a ComboBox that gets populated with a field from a database. What I
    need is that when a name is selected from within that comboBox that it will
    populate another text box with information that is related to the selection
    from that same Database. For Example: User Clicks on Combobox, and picks
    a name. The Phone number for that selected person is then inserted into a
    text box on that form. Please help if you can. Thanks.

  2. #2
    Jim Guest

    Re: Filling in text Box With Combo Select


    "Jason" <iwishiwereme@hotmail.com> wrote:
    >
    >I have a ComboBox that gets populated with a field from a database. What

    I
    >need is that when a name is selected from within that comboBox that it will
    >populate another text box with information that is related to the selection
    >from that same Database. For Example: User Clicks on Combobox, and picks
    >a name. The Phone number for that selected person is then inserted into

    a
    >text box on that form. Please help if you can. Thanks.

    '///////////////////////////////

    Ok, in an sql statement you can do something like:

    ssql = "SELECT * FROM <Database> "
    ssql = ssql & "WHERE <Field> = '" & combobox.text & "'"

    This will return the record(s) where the field = what the combobox.text is.
    If you using DAO, just an example....

    dim db as database
    dim ds as dyanset
    dim sSql as string
    dim sPhoneNumb as string

    ssql = "SELECT * FROM <Database> "
    ssql = ssql & "WHERE <Field> = '" & combobox.text & "'"

    Set db = opendatabase("Datbase path")
    Set ds = db.createdynaset(ssql)

    sPhoneNumb = ds.fields("PhoneNumber").value
    textbox = sPhoneNumb

    ds.close
    set ds = nothing

    This would have to be placed in the click even of the combo box. Like I
    said this is a basic example. If you have to loop through then just add
    a do while loop. Without the code you have it's hard to say. Let us know
    if your still unclear. L8tr

    Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center