tags:

views:

42

answers:

2

How do I make a stored procedure in MS Access?

+2  A: 

If you mean the type of procedure you find in SQL Server, 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.

Remou
See my response here. Access 2010 does now have both triggers and Procedural code that runs at the engine level
Albert D. Kallal
i appreciate your responses, thank you guys.
yonan2236
+2  A: 

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 produces 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.

Eg:

alt text

Note that the store produce language is it own flavor just like Oracle or SQL server (t-sql). Here is example code to update inventory of fruits as a result of a update in the fruit order table alt text

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.

Albert D. Kallal
thanks... very informative :)
yonan2236
Interesting char
Remou