Table of contents
Collapse the table of content
Expand the table of content

Execute Method (ADO Command)

office 365 dev account|Last Updated: 4/3/2018
3 Contributors

Applies to: Access 2013 | Access 2016

In this articleSyntaxReturn ValueParametersRemarks

Executes the query, SQL statement, or stored procedure specified in the CommandText property.


For a Recordset -returning Command:

For a non-recordset-returning Command:

Return Value

Returns a Recordset object reference or Nothing.


  • RecordsAffected

  • Optional. A Long variable to which the provider returns the number of records that the operation affected. The RecordsAffected parameter applies only for action queries or stored procedures. RecordsAffected does not return the number of records returned by a result-returning query or stored procedure. To obtain this information, use theRecordCount property. The Execute method will not return the correct information when used with adAsyncExecute, simply because when a command is executed asynchronously, the number of records affected may not yet be known at the time the method returns.

  • Parameters

  • Optional. A Variant array of parameter values passed with an SQL statement. (Output parameters will not return correct values when passed in this argument.)

  • Options

  • Optional. A Long value that indicates how the provider should evaluate theCommandText property of theCommand object. Can be a bitmask value made usingCommandTypeEnum and/orExecuteOptionEnum values. For example, you could use both adCmdText and adExecuteNoRecords together in combination if you want to have ADO evaluate the value of the CommandText property as text and indicate that the command should discard and not return any records that might be generated when the command text executes.


Using the Execute method on a Command object executes the query specified in the CommandText property of the object. If the CommandText property specifies a row-returning query, any results that the execution generates are stored in a new Recordset object. If the command is not a row-returning query, the provider returns a closed Recordset object. Some application languages allow you to ignore this return value if no Recordset is desired.

If the query has parameters, the current values for the Command object's parameters are used unless you override these with parameter values passed with the Execute call. You can override a subset of the parameters by omitting new values for some of the parameters when calling the Execute method. The order in which you specify the parameters is the same order in which the method passes them. For example, if there were four (or more) parameters and you wanted to pass new values for only the first and fourth parameters, you would pass as the Parameters argument.

Note Output parameters will not return correct values when passed in the Parameters argument.

An ExecuteComplete event will be issued when this operation concludes.

Access for developers forum on MSDN
Access help on
Access help on
Search for specific Access error codes on Bing
Access forums on UtterAccess
Access wiki on UtterAcess
Access developer and VBA programming help center (FMS)
Access posts on StackOverflow

© 2018 Microsoft