This documentation is archived and is not being maintained.

EXECUTE Statement (Microsoft Access SQL)

Office 2007

Used to invoke the execution of a procedure.

Syntax

EXECUTE procedure [param1[, param2[, …]]

The EXECUTE statement has these parts:

PartDescription
procedureThe name of the procedure that is to be executed.
param1, param2, …Values for the parameters defined by the procedure.

Example

This example names the query CategoryList.

This example calls the EnumFields procedure, which you can find in the SELECT statement example.

Sub ProcedureX()

    Dim dbs As Database, rst As Recordset
    Dim qdf As QueryDef, strSql As String
    
    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")
    
    strSql = "PROCEDURE CategoryList; " _
        & "SELECT DISTINCTROW CategoryName, " _
        & "CategoryID FROM Categories " _
        & "ORDER BY CategoryName;"
    
    ' Create a named QueryDef based on the SQL
    ' statement.
    Set qdf = dbs.CreateQueryDef("NewQry", strSql)

    ' Create a temporary snapshot-type Recordset.
    Set rst = qdf.OpenRecordset(dbOpenSnapshot)

    ' Populate the Recordset.
    rst.MoveLast
            
    ' Call EnumFields to print the contents of the 
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 15
    
    ' Delete the QueryDef because this is a
    ' demonstration.
    dbs.QueryDefs.Delete "NewQry"
    
    dbs.Close

End Sub
See Also

PARAMETERS Declaration (Microsoft Access SQL)

PROCEDURE Clause (Microsoft Access SQL)



Show: