×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Execute Stored Procedure With Parameter From Form's Combo Box

Execute Stored Procedure With Parameter From Form's Combo Box

Execute Stored Procedure With Parameter From Form's Combo Box

(OP)
Hi there,

I'm pulling my yhair out over this - have been scanning posts all morning but have got nowhere.

I have a form, with a click button which runs a stored procedure to screen and a combo box which is used to provide a parameter to the stored procedure.

I've this code:

 Dim stDocName As String

     stDocName = "spPartner_Spend_Forecast"
    DoCmd.OpenStoredProcedure stDocName, acViewNormal, acEdit

which runs the stored procedure but I can't pass the parameter to it.

In the SP the parameter is @LC, I want to make LC equal to the selection from combo1.

Ive tried adding @LC = forms!myreport!combo1 to the input parameter of the form, but this tries to filter the form by the combo box.

In an mdb I would put forms!myreport!combo1 in the query as a criteria, but this obviously doesn't work with an adp.

Can anyone help please?

RE: Execute Stored Procedure With Parameter From Form's Combo Box

don't use docmd.openstoredproc...

instead declare a command object

set it's connection to the current project's connection

set the command text to the stored procedures name

incude the parameters in the command text OR set the parameters using the .parameters collection of the command object

--------------------
Procrastinate Now!

RE: Execute Stored Procedure With Parameter From Form's Combo Box

Crowley16,
Doesn't the command object return a recordset and not a datasheet?

DomDom3,

I solved this problem by opening a form in datasheet view with an input parameter specified.  Not elegant, or simple but effective.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close