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
|