Runtime Error: 2342. "A RunSQL action requires an argument consist

R

RichardA

of an SQL statement"

Hello, I cannot figure out what is wrong with the code below. I keep getting the above runtime error. But it runs no problem in Desiqn Query mode, once I've set the primary keys for the two tables. Any idea what the problem is?

Dim strSQL As String
strSQL = "SELECT zmax2.*, rooting2.* " & _
"FROM zmax2 LEFT JOIN rooting2 " & _
"ON zmax2.musym = rooting2.musym"

'Turn off warning message.
DoCmd.SetWarnings False

DoCmd.RunSQL strSQL

'Re-enable warning message
DoCmd.SetWarnings True

RichardA
 
J

John Spencer (MVP)

RunSql requires an action query - DELETE, APPEND, UPDATE, ...

A SELECT query is NOT an action query. What are you trying to accomplish with
this code? Open a recordset? Display a query?
 
V

Van T. Dinh

RunSQL can only be used to run an *Action* Query (Append / Update / Delete),
and NOT a Select Query.

--
HTH
Van T. Dinh
MVP (Access)


RichardA said:
of an SQL statement"

Hello, I cannot figure out what is wrong with the code below. I keep
getting the above runtime error. But it runs no problem in Desiqn Query
mode, once I've set the primary keys for the two tables. Any idea what the
problem is?
 
R

RichardA

Thanks John. You are right. My overall goal is to fill a new, empty column in zmax2 with a calculation based on the minimum of two other columns, one from zmax2,
the other from rooting2.

RichardA
 
R

RichardA

Thanks Van. You are right. My overall goal is to fill a new, empty column in zmax2 with a calculation based on the minimum of two other columns, one from zmax2,
the other from rooting2.

RichardA
 
Z

zulu17

So now whatz the solution if u want to run a select command???
and plzz my program requires to run as a code instead of a query sinc
i need specific variables from the form. :
 
Top