Passing parameter data to stored procedure using VBA?

D

dsstao

Hi all,

I have a stored procedure that includes parameters. I also have a form
that the user can specify criteria on. The problem is, how do I pass
along this info from the form, via VBA, into the parameters of the
stored procedure?

Thanks!
DS
 
C

Cinzia

Hi all,

I have a stored procedure that includes parameters. I also have a form
that the user can specify criteria on. The problem is, how do I pass
along this info from the form, via VBA, into the parameters of the
stored procedure?

Thanks!
DS

Hi DS
you have 2 options:

1) the stored proc is the data source of a form
In this case to pass parameters you can use the InputParameters property of
the form.
In the Open event you can write

me.InputParameters= "@param1 int = forms!Frm_Criteria!TextBox1, @param2
varchar(50) = forms!Frm_Criteria!TextBox2"
or
you can write this string directly in the InputParamters property of the
form

2)you have to run a stored proc who does some work, not associated to any
form.
In this case you can use something like this:

CurrentProject.Connection.Execute "sp_ProcName(" &
forms!frmCriteria!txtBox1 & ", " & forms!Frm_Criteria!TextBox2 & ")"
depending on parameters type you should enclose the parameters between " ' "

For more help the right ng is microsoft.public.access.adp.sqlserver

Bye
 

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