- Local time
- Today, 04:17
- Joined
- Feb 19, 2002
- Messages
- 46,816
I don't like Dwane's method because it temporarily changes a permanent object.
I don't know your application but ONE method is to add a hidden field to the form that opens the report. To make this work, you need to do two things.
1. Change the RecordSource query of the Report to add a where clause that references the hidden form field:
Where SomePK = Forms!myform!myPK
2. When you click on the print report button, copy the PK of the record you want to show to the hidden field.
This method is simple and works fine (also delete the OpenReport in your current code because it is not necessary and just adds unnecessary overhead) -- unless you want to open the same report from multiple forms. In that case, you can use a Tempvar instead of a form control reference.
I don't know your application but ONE method is to add a hidden field to the form that opens the report. To make this work, you need to do two things.
1. Change the RecordSource query of the Report to add a where clause that references the hidden form field:
Where SomePK = Forms!myform!myPK
2. When you click on the print report button, copy the PK of the record you want to show to the hidden field.
This method is simple and works fine (also delete the OpenReport in your current code because it is not necessary and just adds unnecessary overhead) -- unless you want to open the same report from multiple forms. In that case, you can use a Tempvar instead of a form control reference.