When I run this code: in Access 97
===============================
' Create ODBC Workspace object.
Set WS = DBEngine.CreateWorkspace("ODBCDirect", "admin", "", dbUseODBC)
'Open ODBC Connection as CN
Set CN = WS.OpenConnection("ODBCConnect", dbDriverNoPrompt, False,
ConnectString)
SQL = "SELECT .....STUFF ... INTO Indistinct " ' I'm omitting the gory
details because this query works
CN.Execute (SQL)
'Fill RST with distinct Contact_IDs
SQL = "Select distinct Contact_ID from Indistinct"
Set rst = CN.OpenRecordset(SQL)
With rst
SixPercent = (.06 * CN.RecordsAffected)
While Not .EOF And SixPercent > 0
Set QDF = CN.CreateQueryDef("")
'Insert one row for each Contact_ID
SQL = "INSERT INTO DistinctRecords Select * From Indistinct
Where Contact_ID = '" & Trim(rst.Fields(0)) & "'"
QDF.MaxRecords = 1
QDF.Execute (SQL) 'THIS QUERY GETS ERROR MESSAGE *********
SixPercent = SixPercent - 1
'RST2.Close
.MoveNext
Wend
.Close
End With
'END CODE
When the QDF.execute runs I get an ERROR: "Invalid SQL statement: expected
"DELETE", "INSERT", "PROCEDURE", "SELECT" or "UPDATE'
Error Number 3129.
WHY am I getting this error? The same query runs when I use a pass through
query.
Judy Matthis
Delivery Systems
jmatthis@c...
Judy Matthis
Delivery Systems
(xxx) xxx-xxxx
jmatthis@c...
---
You are currently subscribed to sql_language as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-sql_language-$subst('Recip.MemberIDChar')@p2p.wrox.com