In Microsoft Access, VBA code can be used to customize Access reports. Various subroutines can be embedded in the components of the report using “Private Sub”.
The following example applies to the format function/procedure of the Categoryfooter section of the report, so the notes(label) can be customized, showing or hiding the note contents fore specific group.
View of the report design:
The components in the report are objects that be used for VBA coding. The name of the components can be checked through the property window. The name of the components needs to match the object names in the VBA code window.
View of the project explorer:
View of the object and procedure selector in the code window:
In order for the VBA code to be effective, the code section are uniquely named as object_procedure. When you move the cursor from section to section in the code window, the Object and Procedure selector at the top of the code window will always reflect the object and procedure of the section where your cursor is.
Private Sub Categroyfooter_Format(Cancel As Integer, FormatCount As Integer) If Me.level1.Value = "A" Then Me.CategoryFooter.Visible = True Me.catAfootnote.Visible = True Me.catAfootnote.Caption = "*Note:For 18/19, the admission information are as of the reporting date. " ElseIf Me.level1.Value = "C" Then Me.CategoryFooter.Visible = True Me.catAfootnote.Visible = True Me.catAfootnote.Caption = "*Note:For 18/19, the enrolment FTEs are as of the reporting date." Else Me.catAfootnote.Visible = False Me.CategoryFooter.Visible = False End If End Sub