locked
Formatting Report fields RRS feed

  • Question

  • I have a report where, based on a yes/no field in the recordsource, I show or hide the address, city, state, zip.

    When I call the report with print preview (DoCmd.OpenReport "rpt_FittingSheet",acViewPreview , , "ID = " & Me.Recordset.Fields("ID")), I can use the pageheader_onformat event and it will fire and format the address box correctly

    Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
        If Me.ShowHide = 0 Then
            Me.ShippingAddress.Visible = False
            Me.ShippingCity.Visible = False
            Me.ShippingState.Visible = False
            Me.ShippingZip.Visible = False
        Else
            Me.ShippingAddress.Visible = True
            Me.ShippingCity.Visible = True
            Me.ShippingState.Visible = True
            Me.ShippingZip.Visible = True
        End If

    When I open the report in normal view (DoCmd.OpenReport "rpt_Report", , , "ID = " & Me.Recordset.Fields("ID")) it doesnt hit the format event, how do I get it to show or hide the boxes when opened?

    I also have the same question about hiding the report_footer on certain criteria like above

    Tuesday, February 11, 2020 10:42 PM

Answers

  • Try using the On Print event of the section(s) instead of, or in addition to, the On Format event.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by JHarding08 Wednesday, February 26, 2020 5:22 PM
    Tuesday, February 11, 2020 10:58 PM