Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > BOOK: Beginning Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Access VBA
This is the forum to discuss the Wrox book Beginning Access 2002 VBA by Robert Smith, Dave Sussman, Ian Blackburn, John Colby, Mark Horner, Martin Reid, Paul Turley, Helmut Watson; ISBN: 9780764544026
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Access VBA 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 2nd, 2005, 08:21 PM
Registered User
 
Join Date: Feb 2005
Location: Hobart, Tasmania, Australia.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Begging Access 2003 VBA Ch 5 - connection problem

I have been following the example in page 140 in CH5 about establishing an unbounded recordset. I am using the sample to build my own application.

When I try to open the recordset (line .Open "Compliments_Log", cnCompliments & yes the name is spelt corectly) I get an SQL error as follows:


Invalid SQL statement: expected 'DELETE' 'INSERT' 'PROCEDURE' 'UPDATE' ETC

I have followed the code and checked it several times and cannot see the error. Any help please. The code I have written is as follows:

Dim rsCompliments As ADODB.Recordset
Dim cnCompliments As ADODB.Connection
Dim strCompliments As String
----------------------------------------------------

Private Sub Form_Load()

strCompliments = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Access DataBases\KPI_DataBase.mdb"


'create a new connection instance and open it using the connection string

Set cnCompliments = New ADODB.Connection
cnCompliments.Open strCompliments

'create a new instance of a recordset
Set rsCompliments = New ADODB.Recordset


'set various properties of the recordset
With rsCompliments
    'specify a cursortype and lock type that will allow updates
    .CursorType = adOpenKeyset
    .CursorLocation = adUseClient
    .LockType = adLockBatchOptimistic
    'open the recordset based on tblCompliments_Log using the existing connection
    .Open "Compliments_Log", cnCompliments
    'disconnect the recordset
    .ActiveConnection = Nothing
End With


Thank you

Reply With Quote
  #2 (permalink)  
Old February 2nd, 2005, 08:46 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Modify
.Open "Compliments_Log", cnCompliments
as
.Open "select * from Compliments_Log", cnCompliments


http://docs.sun.com/source/817-2514-10/Ch11_ADO123.html

Om Prakash
Reply With Quote
  #3 (permalink)  
Old February 3rd, 2005, 06:45 PM
Registered User
 
Join Date: Feb 2005
Location: Hobart, Tasmania, Australia.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by om_prakash
 Modify
.Open "Compliments_Log", cnCompliments
as
.Open "select * from Compliments_Log", cnCompliments


http://docs.sun.com/source/817-2514-10/Ch11_ADO123.html

Om Prakash
Thank you, that worked, I also found the following worked.

 .Open "Compliments_Log", CurrentProject.Connection

Thanks for the link.

Quixote



Reply With Quote
Reply


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
beg access 2003 vba Michele_Haywood BOOK: Beginning Access VBA 0 November 9th, 2006 09:03 PM
beg access vba 2003 Michele_Haywood Access VBA 0 November 8th, 2006 10:15 PM
Question on Access 2003 VBA Chapter 5 AlexJChang BOOK: Beginning Access 2003 VBA 1 June 7th, 2005 02:04 PM
Question on Access 2003 VBA - Ch5ExampleCode AlexJChang Access 2 June 3rd, 2005 11:10 AM
Access 2003 connection problem umzi ADO.NET 4 July 23rd, 2004 01:04 AM



All times are GMT -4. The time now is 11:36 AM.


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