SQL -- VBA

  • Thread starter Thread starter Jeanne
  • Start date Start date
J

Jeanne

Receive RunTime error ‘2342’
A RunSQL action requires an argument consisting on an SQL statement.

I’m able to run other SQL successfully, Insert, Delete, … cannot run a
Select statement.

I have this same below code running in other applications – no problem.
In this same application I have an SQL Select statement running using this
same Recordset definition -- no problem
My “References†in Tools include “Microsoft ActiveX DataObjects 2.1 Library.

Dim cnn2 As ADODB.Connection
Set cnn2 = CurrentProject.Connection
Dim RcdSet2 As New ADODB.Recordset
RcdSet2.ActiveConnection = cnn2

Dim sSQL As String

sSQL = "SELECT COA_Checking.* FROM COA_Checking"
DoCmd.RunSQL sSQL
 
Dan,

Looked at your attachment, unable to look at the code in the link.

Trying not to be redundant, but I have successfully run the below code many
times. Suddenly, it will NOT work for a particular form I created.
I have the exact code (different SQL) in another place within the same
Access DB.
I don't understand the sudden issue.
Just for the record, my level and reference for the code is Access for
Dummies book. It's been fine up to now.
 
RunSQL REQUIRES an action query. A SELECT query is not an action query as it
does nothing to modify the data in the database.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top