I think I tried to run before I could crawl! I've made an access db which was successful and is being used at the moment. I now want to use vb to connect to it. I can connect to the db but I want to populate text boxes from the fields when a button is clicked (a search if you like.) I type in the name I want and it brings up that person in the boxes. My db is called address, fields are surname and first_name. I can do some things but not populate the boxes. I don't really want to use the data control to go through the fields one by one. Any pointers would be well appreciated or directions to an extremely simple tutorial.
Private Sub command1_click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = E:\address.mdb"
conn.Open
Set rs = conn.Execute("SELECT first_name FROM tblAddress " & "WHERE Surname= '" & txtText3 & "'")
rs.Close
conn.Close
txtText1.Text = dbRecordset.Field(surname)
txtText2.Text = dbRecordset.Field(first_name)
Set rs = Nothing
Set conn = Nothing
End Sub
TIA
Private Sub command1_click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = E:\address.mdb"
conn.Open
Set rs = conn.Execute("SELECT first_name FROM tblAddress " & "WHERE Surname= '" & txtText3 & "'")
rs.Close
conn.Close
txtText1.Text = dbRecordset.Field(surname)
txtText2.Text = dbRecordset.Field(first_name)
Set rs = Nothing
Set conn = Nothing
End Sub
TIA