Click to See Complete Forum and Search --> : listbox
midnightservice
September 28th, 2001, 09:23 PM
i have a listbox connected to a field in my database.....i have 5 textbox's...when the user selects from the list box i would like the textbox's to fill with corresponding info from fields in the same table and database...can this be done or am i reaching for the stars....
midnightservice
Cakkie
September 30th, 2001, 04:10 PM
Of course can this be done. Depending on how you bound your textboxes to the fields in the database. This assumes that the controls are bound via the datasource and datafield properties:
private Sub SearchDAO()
If List1.Text <> "" then
Data1.Recordset.FindFirst "Searchfield='" & list1.Text & "'"
End If
End Sub
private Sub SearchADO()
If List1.Text <> "" then
Data1.Recordset.MoveFirst
Data1.Recordset.Find "Searchfield='" & list1.Text & "'"
End If
End Sub
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
midnightservice
October 1st, 2001, 08:40 PM
okay how does this help me update my text box's.... listbox is field 1 and txtbox1 is field 2 txtbox2 is field3 and so on...so when the user clicks on a choice in the list box the text box's refresh and up date themself according to the database.
thanx
midnightservice
Cakkie
October 2nd, 2001, 02:01 AM
try this
private Sub Listbox1_Click()
If List1.Text <> "" then
rst.MoveFirst
rst.Find "Searchfield='" & list1.Text & "'"
If not(rst.eof) then
txtBox1.Text = rst("Field2")
txtBox2.Text = rst("Field3")
End iF
End If
End Sub
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.