The RunSQL method carries out the RunSQL action in Visual Basic in action queries. For more information on how the action and its arguments work, see the action topic.
This method only applies to Microsoft Access databases (.mdb).
Syntax
DoCmd.RunSQL sqlstatement[, usetransaction]
The RunSQL method has the following arguments.
Argument | Description |
---|---|
sqlstatement | A string expression that's a valid SQL statement for an action query or a data-definition query. It uses an INSERT INTO, DELETE, SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX statement. Include an IN clause if you want to access another database. |
usetransaction | Use True (–1) to include this query in a transaction. Use False (0) if you don't want to use a transaction. If you leave this argument blank, the default (True) is assumed. |
Remarks
The maximum length of the sqlstatement argument is 32,768 characters (unlike the SQL Statement action argument in the Macro window, whose maximum length is 256 characters).
If you leave the usetransaction argument blank, don't use a comma following the sqlstatement argument.