Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 21st, 2008, 06:06 AM
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

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,

Reply With Quote
  #2 (permalink)  
Old May 21st, 2008, 09:11 AM
Authorized User
Join Date: May 2007
Location: , , .
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

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 09:24 AM.

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