I've been going around in circles with this. I want to find out if it iis possible to use a stored procedure with a parameter as a row source? I imagine this would be exactly the same using a query with 'variables' in the where clause.
Is your front end an ADP? ... if NOT ... you can modify the SQL statement of a Passthrough to have the literal values of the arguments you wish to pass to the SP, or, you can open an recordset in VBA, then bind that recordset to a form.
So, as you can see, the sp expects ONE parameter identified as @nvTerminalID and it has the datatype of nvarchar(20) .... so ... since the sp is my recordsource, I will set the "Input Parameters" property (Me.InputParameters in VBA with code behind the form) to the following string:
@nvTerminalID nvarchar(20) = 'D0203419'
{note: if you have multiple parameters, separate the expressions with a comma}
Now when the forms recordsource is queried (ie: an execution of Me.Requery) the value of 'D0203419' is passed to the @nvTerminalID parameter that is expected by my sp.
If you want to use a form control value for your parameter, then the property would look something like this:
With this syntax, your value of the referenced control is passed to the indicated paramter.
...
Here is a sample code snipet the could be attached to a button (if you go that route) ....
Code:
Private Sub cmdResetMyParameter_Click()
Me.InputParameters = "@nvTerminalID nvarchar(20)='D0203419'"
Me.Requery
End Sub
Also, I would suggest that when you use a parameterized sp for your Recordsource, set a value (ie: set the property while in design view) for the Input Parameters property that makes sense when initially opening your form.
... Disclaimer ... its been a while since I've done this in an ADP and I am not near a machine I can verify at the moment ... so I may be off just a bit ...
Also ... as I finishing this up, I am pretty sure you can just enter the values of the parameters in the expected order ... so in the sample I provided, I think I can just enter 'D0203419' on the Input Parameters property ...