Passing Text Box Values to a Stored Procedure

J

Johnny98

I have created a stored procedure which I run using a pass-through query.
The update only works if I hard code the values I am passing. How can I pass
text box values to the stored procedure so that the query is dynamic?

The name of my stored procedure is 'insert_records', and this is what I
would like to be able to pass:

begin
insert_records(txtBox1.value,txtBox2.value, txtBox3.value, txtBox4.value);
end;

Any help would be greatly appreciated!
Thanks,
Johnny
 
D

Duane Hookom

You can change the SQL property of the pass-through query. Code might be
similar to
Currentdb.QueryDefs("qsptMyInsert").SQL ="Exec Insert_Records " & Me.txtBox1
& ", " & Me.txtBox2 & ...""
You might need to concatenate single quotes if some of the control values
are text or dates.
 
J

Johnny98

Thank you for the response. What exactly does the Querydefs method do?
Also, do I need to create the "qsptMyinsert" query?
 
J

Johnny98

Thanks alot! I figured it out from your help!

Duane Hookom said:
You can change the SQL property of the pass-through query. Code might be
similar to
Currentdb.QueryDefs("qsptMyInsert").SQL ="Exec Insert_Records " & Me.txtBox1
& ", " & Me.txtBox2 & ...""
You might need to concatenate single quotes if some of the control values
are text or dates.
 
J

Jason

Hi Johnny,

Could you tell me how you figured it out? I'm having the same problem, but
in my case a select statement with criteria.

Greetings,

Jason
 

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