Printing and export

  • Thread starter Thread starter Jörg Werner
  • Start date Start date
J

Jörg Werner

I want to hide a field in a report depending on the value of a checkbox. I
use the Report_open event.

Private Sub Report_Open(Cancel As Integer)
Me.txtStorno.Visible =
(Forms!frmMain!frmAuswertungProjekt.Form.optStorno = 1)
End Sub

If I use 'DoCmd.OpenReport strReport, acViewPreview ' everything works
fine.
But if I use 'DoCmd.OutputTo acOutputReport, strReport, acFormatRTF,
strReport & ".rtf", True' to export the report, the field will always be
visible whether the optStorno = 1 or not.

I discovered that the Report_Open event will not fire. And so doesn't the
Report Detail Section's Format event.

So how can I generate a report that looks like the preview?

Thanks

Jörg
 
Why do this in the report open event?

Just use conditional formatting for the field.

If the the checkbox is true, make the font normal. If it is false, make the
text white and the background white.

Rick B

I want to hide a field in a report depending on the value of a checkbox. I
use the Report_open event.

Private Sub Report_Open(Cancel As Integer)
Me.txtStorno.Visible =
(Forms!frmMain!frmAuswertungProjekt.Form.optStorno = 1)
End Sub

If I use 'DoCmd.OpenReport strReport, acViewPreview ' everything works
fine.
But if I use 'DoCmd.OutputTo acOutputReport, strReport, acFormatRTF,
strReport & ".rtf", True' to export the report, the field will always be
visible whether the optStorno = 1 or not.

I discovered that the Report_Open event will not fire. And so doesn't the
Report Detail Section's Format event.

So how can I generate a report that looks like the preview?

Thanks

Jörg
 
You're right. It's a solution to the visible/hide problem. But I have some
other actions (counting etc.) in the detail/footer format/print events. Why
do these events not fire when exporting to RTF?

Jörg
 
Just a thought, as I think I've found similar issues.

When you preview it, the vba runs and will change the
field to visible or not. When you "output" it, it doesn't.

Aside from doing the conditional formatting, which I have
found to be the easiest solution, the only suggestion I
can make is try opening the report before outputting it.
(don't forget to close it afterwards)

eg:
'This line will open the report in preview, which you have
no isses with
docmd.openreport strReportName, acPreview
'this line will export what you see on the screen, as it
is already open
docmd.outputto acFormatRTF, strReportName
'If you don't close it it will staty open
docmd.close acReport, strReportName

(Can't remember the exact syntax of each of the commands,
but hopefully you get the idea.)

Regards,

Fraser.
 
Back
Top