Can a macro be linked to a new page (1 Viewer)

William86

Registered User.
Local time
Today, 10:56
Joined
Jan 29, 2015
Messages
27
I am using Access 365.
I have a report listing transactions, grouped on different offices. Each group starts on a new page via the "force new page before section" property setting for the group header. The group header contains the labels for the headings for the data fields in the detail.
The totals for the data fields and some calculated figures are in the group footer. I want to print the last page for each group, which is the group footer, without the group header on it.
I was thinking about having a macro set the value of the [Visible] field to "NO" for all of the headings labels in the group header ... but then this needs to be linked somehow to only run when the group footer is printed or displayed. Can someone tell me what I am missing ... there must be an easier way of doing this?:banghead:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:56
Joined
May 7, 2009
Messages
19,241
create a private report variable that will hold your current group header text.
on load event of your report set the value of this variable to group header text.
on detail retreat event, set the variable to any string not in your group.
in group header print event, test if this variable is same as the current group header text.
if it is, set its repeatsection property to true.
if not, set its repeatsection property to false.
 

William86

Registered User.
Local time
Today, 10:56
Joined
Jan 29, 2015
Messages
27
Thanks for your reply. I am an amateur with this and although I more or less understand what you are suggesting, it is far beyond my ability to actually do it. Is there an easier way of doing it with a macro?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:56
Joined
May 7, 2009
Messages
19,241
i dont know if you can do it in macro.
since macro is limited, and report events/property are not exposed in macro.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:56
Joined
May 7, 2009
Messages
19,241
anyway it only takes small code to produce the result:
Code:
Option Compare Database
Option Explicit

Private strGroup As String

Private Sub Detail_Retreat()
    strGroup = "~@X"
End Sub

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
    If strGroup <> Me.Group_Of_Category Then
        Me.GroupHeader0.RepeatSection = False
        strGroup = Me.Group_Of_Category
    Else
        Me.GroupHeader0.RepeatSection = True
    
    End If
End Sub

Private Sub Report_Load()
    strGroup = Me.Group_Of_Category
End Sub
 

Users who are viewing this thread

Top Bottom