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 - ReportBottomAligned.mdb
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

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


 Post Reply Post Reply
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: ReportBottomAligned.mdb
    Posted: 07 Jul 2008 at 10:34pm

Updated On: 27-Dec-2011
Explanatory Notes

    This sample db demonstrates bottom alignment of text in various text boxes in an access report.
It involves dynamic adjustment of top margins in such a manner that for each record, grown height
of each text box in the detail section matches that of the tallest one, at the same time ensuring uniform
bottom alignment.    
    Dynamic height (grown height) of a control can be captured only in the print event. However,
direct manipulation of control's size or position is not allowed in this event. For consistent results,
necessary adjustment in top margin should be made in the format event. In the sample db, this
objective is achieved by two stage opening of report. In the first stage, grown heights of controls,
as exposed during print event are stored in a temporary table (T_Temp). These values are then
used to adjust the heights and top margins of controls during second stage opening of report.

    Two styles of report with bottom alignment of text are covered:
    (a) Simple - Without grid lines.
    (b) With grid lines - Spreadsheet style

    Except for the name of row counter text box, generic code is used so as to automatically suit
any number and nomenclature of controls. 

    While drawing vertical grid lines in style (b) above, the locations are set programmatically in

such a manner as to fall mid-way between adjacent controls. 

    For optimum effect, it has been ensured that top margin of first control displaying row numbers

is dynamically kept identical to that of next adjoining control.
    The following alternatives stand rejected:
    (a) If top margins were to be manipulated within print event itself, corresponding effect on
grown height would have been out of sync, getting manifested only upon firing of next print event.
    (b) Padding up the shorter control with suitable number of vbcrlf's in print event, so as to match
its grown height with the taller one is also found to work. The rows of text in each control are
calculated by taking into account the TextWidth property as compared to  control's width.
However, it runs into a snag. The wrapped text does not leave uniform side margins (visa vis
the control's borders) on each line. This detracts from precise calculation of the number of rows
occupied by the contents of different controls. As such, if this alternative were to be adopted, the
results might not always measure up to the desired level of perfection.
This update overcomes the need to navigate through each page of report so as to fetch grown
heights of controls as revealed in print event, thereby eliminating dependence upon either SendKeys
method or Stephen Leban's API based page turner function. It is understood that SendKeys stands
broken in Windows 7 while Leban's function fails to work in Access 2010. Instead, Setting report's
MoveLayout property to false in first stage opening of report, as used in this version is found most
dependable as it shrinks the report to a single page, ensuring that print events for all records get fired
without having to  move away from first page.
Version: Access 2000 File Format
Reference: DAO 3.6

Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.