Results 1 to 4 of 4

Thread: Select data loaded into a combobox to appear in a textbox

  1. #1

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    New Zealand
    Posts
    40

    Select data loaded into a combobox to appear in a textbox

    Once i load the database into the combo box depending on which item you select it should change to the appropriate data for textbox 1,2 and three.
    EXAMPLE:
    COMBOBOX1= list of friends names (Loaded From database)
    TEXT1,2,3= there address, phone number.
    Everytime you select there name in the combobox there addres and phone number should automatically be updated into the textboxs.

  2. #2
    Addicted Member reznor's Avatar
    Join Date
    May 2001
    Location
    Netherlands
    Posts
    151
    if you got the recordset open you could use the find method of the recordset in the onclick event of the combobox; something like this:
    VB Code:
    1. Private Sub Combo1_Click()
    2.    rs.Find "Name = '" & Combo1.List(Combo1.ListIndex) & "'"
    3.    Text1.Text = rs("Address")
    4.    Text2.Text = rs("PhoneNumber")
    5.    etc
    6. End Sub

    hope this helps,
    Rick
    "Computers are incredibly fast, accurate and stupid. Human beings are incredibly slow, inaccurate and brilliant. Together they are powerful beyond imagination." - Albert Einstein

  3. #3
    Lively Member venom8's Avatar
    Join Date
    Jul 2001
    Location
    Quezon City, PHIL.
    Posts
    87
    or u can do this:

    --------------------------------------------------------------------------------
    Private Sub Combo1_Click()

    sqlstr= "Select * from MyTable where Name = '" & Combo1.List(Combo1.ListIndex) & "'"
    MyRecordset.Open

    With MyRecordset

    If Not .BOF And Not .EOF then 'record exist

    'display the data
    Text1.Text = .Fields!Address
    Text2.Text = .Fields!PhoneNumber
    etc...

    End if

    End With

    MyRecordset.Close


    End Sub


    hope this one helps too ! i'm just wondering how to post a code that appear like it's VB code?
    You never become a failure, unless you quit on trying!!!

  4. #4
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    Use [.vbcode ] and [./vbcode], but without those periods in there. I did that so it wouldn't actually think I was trying to write it.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

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