View Single Post
  #1 (permalink)  
Old May 21st, 2008, 06:06 AM
rohit_ghosh rohit_ghosh is offline
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
cnmastertable.Open strConnection

Set rslist = New ADODB.Recordset

With rslist
    .CursorType = adOpenKeyset
    .CursorLocation = adUseClient
    .LockType = adLockBatchOptimistic
    .Open "tblData", cnmastertable
    .ActiveConnection = Nothing
End With

cnmastertable.Close
Set cnmastertable = Nothing

End Sub

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

Many Thanks,
Rohit

Reply With Quote