• Try the following code to execute a stored procedure from VBA

    Dim cnn As ADODB.Connection

    Dim rst As ADODB.Recordset

    Dim cmd As ADODB.Command

    Dim strConnect As String

    strConnect = "Connection String to the Database"

    ' Instantiate the connection object

    Set cnn = New ADODB.Connection

    ' Open the connection based on the strConnect connect string arguments

    cnn.Open strConnect

    ' Instantiate the command object

    Set cmd = New ADODB.Command

    ' Assign the connection and set applicable properties

    cmd.ActiveConnection = cnn

    cmd.CommandText = "Stored Procedure Name"

    cmd.CommandType = adCmdStoredProc

    ' Instantiate the recordset object by using the return value

    ' of the command's Execute method. Supply the parameters by

    ' packing them into a variant array

    Set rst = cmd.Execute

    Set rst = Nothing

    Set cnn = Nothing

    Set cmd = Nothing