Passing Active Form Name to Report Input Parameter (ADP)

  • Thread starter Aad v via AccessMonster.com
  • Start date
A

Aad v via AccessMonster.com

Hi Access Profs,

I create a report which has a stored procedure as control source.
To select the right record for the report, the ID of the active record in
'MY_FORM' is passed to the Input Parameter property.
( @REJ_ID int=Forms![MY_FORM]![REJ_ID] ) This works fine as long I refer to
'MY_FORM'.

I now want to use this as generic Report which can display the records of
similar forms.
(the forms are identical except that they have an different customer ID which
will be stored in the table.
In that way I can restrict the recordset to only those of a particular
customer)

So I think that the reference to the active Form has to be dynamic.

I can't figure out how to pass the current Form name to the Report Input
Parameter property.

Please help.

Very Thanks

Aad
 
M

MGFoster

Aad said:
Hi Access Profs,

I create a report which has a stored procedure as control source.
To select the right record for the report, the ID of the active record in
'MY_FORM' is passed to the Input Parameter property.
( @REJ_ID int=Forms![MY_FORM]![REJ_ID] ) This works fine as long I refer to
'MY_FORM'.

I now want to use this as generic Report which can display the records of
similar forms.
(the forms are identical except that they have an different customer ID which
will be stored in the table.
In that way I can restrict the recordset to only those of a particular
customer)

So I think that the reference to the active Form has to be dynamic.

I can't figure out how to pass the current Form name to the Report Input
Parameter property.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Instead of using the value of a control on a form, why not just pass the
value to the report when you open it?

Use the DoCmd.OpenReport's OpenArgs parameter to pass the value. In the
Report's OnOpen event procedure read the OpenArgs value & place it in
the report's Input Parameter property. E.g.:

' In the form that is calling the report:
DoCmd.OpenReport "ReportName", OpenArgs:= Me!CustomerID

' The report's OnOpen event procedure
Private Sub Report_Open(Cancel As Integer)

If Not IsNull(Me.OpenArgs) Then
Me.InputParameters = "@CustomerID = " & Me.OpenArgs
Else
MsgBox "Missing Customer ID", vbCritical
Cancel = True
End If

End Sub
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQxdKDoechKqOuFEgEQItUwCg/uXvyJXNPR/Yc1FJzeJifeZVf00AnjT0
x/5pqt1G6VwUAJ0X6tpMTQ3f
=BuPt
-----END PGP SIGNATURE-----
 
A

Aad v via AccessMonster.com

Thanks for your reply.

My problem It almost solved.

When the report opens it always shows the first record instead of the active
record.
However, when entering design mode (report) the Input Parameter property
shows the correct (active) ID number. Then, when entering View mode again the
correct record is displayed in the report.

It seems that when the report opens, the ID number is not passed at that
time.

Any suggestions?

Aad.





The OpenArgs:= Me!CustomerID passes the right ID number (I have checked that
in VB editor), but it seems that in the
Hi Access Profs,
[quoted text clipped - 15 lines]
I can't figure out how to pass the current Form name to the Report Input
Parameter property.

Instead of using the value of a control on a form, why not just pass the
value to the report when you open it?

Use the DoCmd.OpenReport's OpenArgs parameter to pass the value. In the
Report's OnOpen event procedure read the OpenArgs value & place it in
the report's Input Parameter property. E.g.:

' In the form that is calling the report:
DoCmd.OpenReport "ReportName", OpenArgs:= Me!CustomerID

' The report's OnOpen event procedure
Private Sub Report_Open(Cancel As Integer)

If Not IsNull(Me.OpenArgs) Then
Me.InputParameters = "@CustomerID = " & Me.OpenArgs
Else
MsgBox "Missing Customer ID", vbCritical
Cancel = True
End If

End Sub
 
A

Aad v via AccessMonster.com

Thanks for your reply.

My problem It almost solved.

When the report opens it always shows the first record instead of the active
record.
However, when entering design mode (report) the Input Parameter property
shows the correct (active) ID number. Then, when entering View mode again the
correct record is displayed in the report.

It seems that when the report opens, the ID number is not passed at that
time.

Any suggestions?

Aad.
 
Top