Try something like this. Add a reference to Microsoft ActiveX Data Objects 2.x Library:
Assuming that C:\MyDB.mdb is my database, Customer is my table and CustomerId is a criteria for my record.Code:Private Sub Command1_Click() Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim i As Integer cn.Provider = "Microsoft.Jet.OLEDB.4.0" cn.Open "C:\MyDB.mdb", "admin", "" rs.Open "Select * From Customer Where CustomerId = YourNumber", cn, adOpenStatic If Not rs.EOF Then For i = 0 To rs.Fields.Count - 1 Text1(i).Text = rs.Fields(i).Value Next End If rs.Close Set rs = Nothing cn.Close Set xn = Nothing End Sub
Also, make sure that you have enough textboxes on the form (i.e. the number of Textboxes should match the number of fields in the table)
Regards,




Reply With Quote