It depends!

N

Nick

There are three ways to run a sp in an ADP command
button. Do you need to just execute it, run it and return
a recordset or pass parameters and run it? to run it and
pass parameters is the most control:

'you need a connection to the DB, a command to hold the sp
'and a parameter to tell the command the parameters
dim cnn as adodb.connection
dim cmd as adodb.command
dim prm as adodb.parameter
dim rst as adodb.recordset

'set up the obejcts
set cnn = currentproject.connection
set cmd = new adodb.command
set rst = new adodb.recordset

'set the command to the connection and some properties
cmd.activeconnection = cnn
cmd.commandtext = "<your SQL proc name or a sql statement>"
cmd.commandtype = adcmdstoredproc

'repeat this for each parameter --
'return, inputs then output is the order from the sp!
set prm = cmd.createparmeter(fill in the stuff)
cmd.parameters.append prm

set rst = cmd.execute()

'now you have a command object with your result set, too
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top