Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto populate fields using command Buttons

Status
Not open for further replies.

kptasteve

Programmer
Nov 2, 2002
43
0
0
US
I would like to have a Form - frmEVAL - that has ten fields, fldArea, fldSide, fldmotion, and so on ... I would like to use a command button that populates the fields with data of ten appropriate information from another TABLE that has the ten associated data. How can this be done programmatically. Thanks

Steve Marcum PT
Programmer
 
Use a recordset .... Something like :

Private Sub cmdButton_Click()
Dim rs as ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM AnotherTables WHERE ..."
If Not rs.eof then
fldArea = rs!Area
fldSide = rs!Side
fldmotion = rs!Motion
....
Else
fldArea = ""
...
End if
End Sub

The WHERE condition may be user to locate the information in the other table. ie :

"SELECT * FROM AnotherTables WHERE Id=" & me.FieldToSearch






 
Can you give me an examle of the where statement using the value of a list box as the ID.

Steve Marcum PT
Programmer
 
if the bound column of the List box is the Id, you can use the following code:

"SELECT * FROM AnotherTables WHERE Id=" & ListName

if your listbox is multicolumn you can use any column value that you want:

"SELECT * FROM AnotherTables WHERE OtherField=" & ListName.Column(3)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top