Access Reports - Hiding fields, labels and other items based on data

I am trying to format a report to provide a list of vendor prospects that shows the equipment model number, serial number, range, asset number, and calibration frequency. The concept is based on the fact that this proposal, if accepted, will later become a purchase order, so the fields are provided as if the work was done in the house, as well as when the proposal was created, when we propose to send the items, and finally if there is a valid PO number already assigned to the whole mess.

I am trying to have a field that changes the value based on whether the value of the Yes / No checkbox in the underlying query is True or False. However, I can't get any standard property changes to work in the report - it doesn't throw errors, it just doesn't do anything. I tried to inject my code into the On Format event as well as the On Load event on the appropriate form, but the code just won't fire.

Are these kinds of data manipulations, based on the values ​​of the underlying query field, used for reports like they do for forms?

+2


source to share


4 answers


Create an unbound text box in the control's Source property in the formula:



=IIF([BooleanField],"Value if True","Value if false")

      

+4


source


I think it would be better to assign the value (s) in the query rather than the report.

Small sample code:



Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me.YN Then
    ''Label in the detail section
    Me.Label_YN.Visible = False
    ''Unbound field
    Me.txtField1 = "abc"
Else
    Me.Label_YN.Visible = True
    Me.txtField1 = "def"
End If
End Sub

      

+1


source


When generating a report, you probably want to put your code in the onPrint event. It starts when you print to the screen.

0


source


This is slightly different from your specific question, but it can be a useful alternative approach in terms of report design.

You might want to put the "internal" data in a separate sub-report that is linked to the main report (for example, by the main work order number). The data for the additional report is taken from a new table that contains internal data, including the number of the main job). Then you join the master table data to the new table with the master work order number.

If the main report does not have a link to a secondary report, there should be no data displayed (there should be no code). You can set the details of the main report as needed, and the sub-report "can shrink" attribute is "yes" if you want to close the blank space for a blank sub-report.

The advantage of this approach is that the new table can have multiple entries for a given work order number, for example, for different executive departments. In addition, the design of the sub-report can be changed separately without affecting the main report (except for the size).

0


source







All Articles