How do I make a stored procedure in MS Access?
2 Answers
Access 2010 has both stored procedures, and also has table triggers. And, both features are available even when you not using a server (so, in 100% file based mode).
If you using SQL Server with Access, then of course the stored procedures are built using SQL Server and not Access.
For Access 2010, you open up the table (non-design view), and then choose the table tab. You see options there to create store procedures and table triggers.
For example:
Note that the stored procedure language is its own flavor just like Oracle or SQL Server (T-SQL). Here is example code to update an inventory of fruits as a result of an update in the fruit order table
Keep in mind these are true engine-level table triggers. In fact if you open up that table with VB6, VB.NET, FoxPro or even modify the table on a computer WITHOUT Access having been installed, the procedural code and the trigger at the table level will execute. So, this is a new feature of the data engine jet (now called ACE) for Access 2010. As noted, this is procedural code that runs, not just a single statement.

- 42,438
- 18
- 116
- 138

- 42,205
- 3
- 34
- 51
-
the user doesn't say anything about SQL Server. – Aaron Kempf May 11 '11 at 01:56
-
2The answer above, Aaron, isn't about SQL Server. Do the screenshots look like SQL Server to you? – David-W-Fenton May 12 '11 at 02:56
-
Interesting...sadly (deliberate crippling I presume) many shortcomings though: http://blogs.office.com/b/microsoft-access/archive/2009/08/13/access-2010-data-macros-similar-to-triggers.aspx – tbone Apr 09 '12 at 02:19
-
1Why is it that the buttons you have highlighted are greyed out for me when I open a table? – Shane LeBlanc Feb 04 '13 at 13:52
If you mean the type of procedure you find in SQL Server, prior to 2010, you can't. If you want a query that accepts a parameter, you can use the query design window:
PARAMETERS SomeParam Text(10);
SELECT Field FROM Table
WHERE OtherField=SomeParam
You can also say:
CREATE PROCEDURE ProcedureName
(Parameter1 datatype, Parameter2 datatype) AS
SQLStatement
From: http://msdn.microsoft.com/en-us/library/aa139977(office.10).aspx#acadvsql_procs
Note that the procedure contains only one statement.

- 90,370
- 7
- 114
- 152
-
See my response here. Access 2010 does now have both triggers and Procedural code that runs at the engine level – Albert D. Kallal Jul 21 '10 at 04:54