Getting a parameter from a form into a Report RecordSource

  • Thread starter Thread starter Url Onz
  • Start date Start date
U

Url Onz

I have a stored procedure that I want to use for the
record source of a form. I can put the record source in
the properties box as "Exec ip_rpt 12345" where "12345" is
the parameter I am passing. Now what I need to do is to
get a simple way to pass the parameter to the proc. It
would be nice to get it from a form. I could then code a
comanc button to open the report.
 
Set the recordsource of the report to be the stored procedure. Then put the
parameter value you would like to pass in the Input Parameters. Remember,
if you're referencing a control on another form (which you are) you need to
specify that form's name.

Record Source: ip_rpt
Input Parameters: Forms!SomeForm!SomeTextbox

You may have noticed that when you run a report based on a parameterized sp,
the report will prompt you for those values before generating the report.
The Input Parameters property does that for you.

Andy-
 
I never thought of that. I did it by putting the
RecordSource code in the Report module. I'll try your way
too. It looks more elegant.
Here's what I put in the mod:
Private Sub Report_Open(Cancel As Integer)
Dim cn As String
cn = Forms!frmOlderCaseJobOffer!txtCN.Text
Me.RecordSource = "Exec ip_rpt " & cn
End Sub
 
Back
Top