Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

In an Access project (*.adp), you can use the OpenStoredProcedure macro action to open a stored procedure in Datasheet view, stored procedure Design view, or Print Preview. This action runs the named stored procedure when opened in Datasheet view. You can select the data entry mode for the stored procedure and restrict the records that the stored procedure displays.

Note: This action will not be allowed if the database is not trusted.

Note: Access 2010 is the last version that supports Access data projects.


The OpenStoredProcedure macro action has the following arguments.

Action argument


Procedure Name

The name of the stored procedure to open. The Procedure Name box box in the Action Arguments section of the macro design window shows all stored procedures in the current database. This is a required argument.

If you run a macro containing the OpenStoredProcedure macro action in a library database, Access first looks for the stored procedure with this name in the library database, and then in the current database.


The view in which the stored procedure will open. Click Datasheet, Design, Print Preview, PivotTable, or PivotChart in the View box. The default is Datasheet.

Data Mode

The data entry mode for the stored procedure. This applies only to stored procedures opened in Datasheet view. Click Add (the user can add new records but can't view or edit existing records), Edit (the user can view or edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.


This action is similar to double-clicking the stored procedure in the Navigation Pane, or right-clicking the stored procedure in the Navigation Pane and selecting the command you want.

Switching to Design view while the stored procedure is open removes the Data Mode argument setting for the stored procedure. This setting is not in effect, even if the user returns to Datasheet view.


  • You can drag a stored procedure from the Navigation Pane to the macro design window. This automatically creates an OpenStoredProcedure macro action that opens the stored procedure in Datasheet view.

  • If you do not want to display the system messages that normally appear when a stored procedure is run (indicating it is a stored procedure and showing how many records will be affected), you can use the SetWarnings action to suppress the display of these messages.

To run the OpenStoredProcedure macro action in a Visual Basic for Applications (VBA) module, use the OpenStoredProcedure method of the DoCmd object.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!