Roger's Access Library Homepage
Forum Home Forum Home > Other Download Libraries > MS Access MVP Libraries > Tejpal, A.D.
  New Posts New Posts RSS Feed - Report_HideGrpHdrsIfNoDetail
  FAQ FAQ  Forum Search   Events   Register Register  Login Login


Please consider donating $1 per sample downloaded, (find out why here)

Report_HideGrpHdrsIfNoDetail

 Post Reply Post Reply
Author
Message
A.D. Tejpal View Drop Down
Microsoft MVP
Microsoft MVP


Joined: 30 Jun 2008
Status: Offline
Points: 192
Post Options Post Options   Thanks (0) Thanks(0)   Quote A.D. Tejpal Quote  Post ReplyReply Direct Link To This Post Topic: Report_HideGrpHdrsIfNoDetail
    Posted: 02 Dec 2008 at 11:09pm

Report_HideGrpHdrsIfNoDetail
Sample Db - Explanatory Notes

    This sample db demonstrates run time hiding of group headers and footers in access reports, if there are no longer any printable records for the group as a result of conditional cancellation of detail section's format event.    

    This functionality is achieved by using a set of two classes. The main class (C_CondHeaders_Main) determines the maximum existing number of group levels and report sections, apart from building up a list of unique group keys. This class also builds up a collection of objects conforming to sub-class (C_CondHeaders_Sub).
 
    Each instance of the subclass represents a group header or footer section. Instead of trying to pass report section object as an argument, simply the section index is supplied, thereby circumventing the hurdle otherwise faced. Corresponding report section object (WithEvents) is generated within the sub-class.
 
    List of unique group keys generated in ShowDetal method of main class gets pushed to the sub-class via the latter's ShowGroups property. Action for hiding the group header / footer as applicable, is carried out in the sub-class.
 
    With the combination of two classes as outlined above, the arrangement becomes completely generic, capable of handling any number of grouping levels. At the same time, the code becomes drastically shorter and compact.

IMPORTANT:
    1 - The report must have a calculated text box having [Pages] as part of its expression.
    2 - Each group header section should have a text box bound to that level's ControlSource field
    3 - If there are any sorting/grouping levels above the last header which do NOT have headers, then for each such level, the  report must include a textbox (may be hidden) located in Detail section, bound to the field serving as group's ControlSource.

USAGE - In Report Module:
===============================
Declarations Section:
Private cRh As New C_CondHeaders_Main

In Report_Open:
Set cRh.ReportObject = Me

In Report_Close:
Set cRh = Nothing

Last statement in existing Detail_Format:
If Cancel = False Then cRh.ShowDetail
===============================

Reference required - DAO 3.6

Version - Access 2000 file format

 
 
--

Email: adtejpal@gmail.com
Back to Top
Sponsored Links


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down