Printing and export

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
 
R

Rick B

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
 
J

Jörg Werner

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
 
F

Fraser

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top