VBA DoCmd.RunSQL

  • Thread starter Thread starter Karen Boyer
  • Start date Start date
K

Karen Boyer

The following statement produces an error that DoCmd.RunSQL requires an
argument that is an SQL statement:

DoCmd.RunSQL "SELECT * & _
"FROM _SCHOOLS"

_SCHOOL is the name of my Access table.

Why is this not a valid SQL statement?

Thank you for your advice.


Sincerely,

Karen Boyer
Xetex Business Systems
610-898-1551
1-800-356-2772
Ext 12
 
Karen Boyer said:
The following statement produces an error that DoCmd.RunSQL requires an
argument that is an SQL statement:

DoCmd.RunSQL "SELECT * & _
"FROM _SCHOOLS"

_SCHOOL is the name of my Access table.

Why is this not a valid SQL statement?

Thank you for your advice.

Is the name _SCHOOL or is it _SCHOOLS? You have it both ways.
In either case you need an action statement (INSERT INTO, DELETE,
SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX,
or DROP INDEX) rather than just a SELECT and you also need a semi-colon at
the end of the SQL statement.

Tom Lake
 
The following statement produces an error that DoCmd.RunSQL requires an
argument that is an SQL statement:

DoCmd.RunSQL "SELECT * & _
"FROM _SCHOOLS"

_SCHOOL is the name of my Access table.

Why is this not a valid SQL statement?

Thank you for your advice.

Sincerely,

Karen Boyer
Xetex Business Systems
610-898-1551
1-800-356-2772
Ext 12

You can only run an Action query (Update, Append, Delete, etc.) using
RunSQL, not a Select Query.

Read VBA help on the RunSQL method.

Note If "_School" is the name of the table, you using
"From _Schools" in the SQL.
_School is not the same as _Schools.
 
Back
Top