|
-
Jul 26th, 2001, 02:32 AM
#1
Thread Starter
Member
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.
-
Jul 26th, 2001, 02:58 AM
#2
Addicted Member
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:
Private Sub Combo1_Click()
rs.Find "Name = '" & Combo1.List(Combo1.ListIndex) & "'"
Text1.Text = rs("Address")
Text2.Text = rs("PhoneNumber")
etc
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
-
Jul 26th, 2001, 03:19 AM
#3
Lively Member
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!!!
-
Jul 26th, 2001, 03:24 AM
#4
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|