How to interact with data using ADO
I am trying to send information via my form in access in a table in the same database. I want to do this with ADO but it wont work.
My General Declarations are( The General Declarations are not working):
Dim cnmastertable As ADODB.Connection
Set cnmastertable = CurrentProject.Connection
Dim rslist As ADODB.Recordset
Dim strConnection As String
My Code in the Form_Load event type is:
Private Sub Form_Load()
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Sources=" & CurrentProject.Path & "\List.mdb;"
Set cnmastertable = New ADODB.Connection
Set rslist = New ADODB.Recordset
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.Open "tblData", cnmastertable
.ActiveConnection = Nothing
Set cnmastertable = Nothing
I am unable to make the above code work. I do not want to see the existing data in the table tblData. I only want to pass recordset on it based on the records that I type on my form.
The Controls in the form are Name, date and Telephone No.
Please can someone help me rectify my code and also add additional codes to send the data from the controls in the columns in the tblData Table. The tblData Table also has the columns with identical names.
The name of the MDB file is List.mdb
The Form Name is frmList
The name of the table is tblData