Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 21st, 2008, 06:06 AM
Authorized User
Join Date: May 2007
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

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,

Old May 21st, 2008, 09:11 AM
Authorized User
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts

I Have tried modifying the code to the below stated one. But I am still unable to do it. I am getting a Compile error (Invalis Use of Property) at Set Me.Name = rstblCLMasterData!Name Please can somebody help me.....

Private Sub Form_Load()

Dim rstblData As ADODB.Recordset
Set rstblData = New ADODB.Recordset
With rstblData
    .ActiveConnection = CurrentProject.AccessConnection
    .Source = "Select Name, Name FROM tblData"
    .LockType = adLockReadOnly
    .CursorType = adOpenKeyset
    .CursorLocation = adUseClient
End With
Set Me.Name = rstblCLMasterData!Name
Set rstblData = Nothing

Many Thanks

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to interact with Biometric devices ? indiangeeks Pro PHP 1 March 7th, 2007 06:27 AM
NEWBIE - Interact with checkbox latieshajohnson Classic ASP Basics 3 December 19th, 2006 05:12 PM
2 different DBs.how they can interact to one anoth saif44 ASP.NET 2.0 Basics 1 March 2nd, 2006 06:32 AM
Interact with files Snib Javascript How-To 4 November 19th, 2003 02:17 PM
Loading Images & Interact with Outlook wasaan SQL Server ASP 1 August 4th, 2003 06:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.