Free Newsletters:
DatabaseJournal  
DBANews
Database Journal
Search Database Journal:
 
HOME News MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc Scripts Links Discussion
internet.com

» HOME
» NEWS
» FEATURES
» SERIES
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Products
Scripts
Links
» DISCUSSION
» TECH JOBS

Marketplace Partners
Be a Marketplace Partner




internet.commerce
Be a Commerce Partner
Promotional Products
Computer Hardware
Auto Insurance Quote
Web Design
Compare Prices
Baby Photo Contest
KVM Switches
Laptops
Promotional Golf
Dental Insurance
Career Education
Online Shopping
Car Donations
Memory




MySpace Joins eBay, Yahoo in Open Profile Push

News Corp. Unit Under Fire for Ties to Hacker

Are Non-PC Devices Hurting 'Net Innovation?

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Linked Data Planet Conference & Expo

CA ERwin® Data Modeler Proven database design and modeling. Efficiently analyze, design and deploy effective database solutions. Whitepaper: Manage SQL Server Deployments
Try it free: CA ERwin® Data Modeler


Solaris 8 Migration Assistant
Rapidly move your Solaris 8 application environments to new systems running Solaris 10 with the Solaris 8 Migration Assistant. Reduce migration risk while taking advantage of increased performance, reliability and security of the latest SPARC hardware platforms and Solaris 10 OS. »

 
Sun Eco Innovation: Good for Business, Good for the Environment
A complete solution to help you optimize and refresh your datacenter while properly recycling equipment and eliminating eWaste, including money-saving promotions to lower hardware acquisition costs. »

 
Sun Eco Innovation: Power Calculators
Power consumption has increasingly become a priority in customer's minds when purchasing new systems or storage. Sun's Power Calculators provide data on power consumption of Sun products allowing IT managers to better plan the power requirements in the datacenter to achieve better energy and cost savings. »

 
Optimize the Web Tier: Consolidate to Get More Performance in Less Space and Lower Power Consumption
Expansion in the Web tier is generally accomplished by adding more servers whenever extra capacity is needed. As the pool of servers grows larger, however, the complexity of the environment can grow exponentially. »

Production Manager (hands on)
Aquent
US-MA-Cambridge

Justtechjobs.com Post A Job | Post A Resume
MS Access
November 21, 2003
Access Report Tricks
By Danny Lesandrini

I have said it before, and I will say it again; Access is the best reporting tool on the market. Anyone who thinks otherwise just has not experienced the power of writing reports in Microsoft Access. Power? Yes, and plenty of it. Follow along as I demonstrate just a few examples of things you can do with Access reports.

Simple, but Powerful

  • Standardize Report Captions
    The Report Caption is the text that shows up in the blue title bar of the window.  There is a property in the report designer that allows you to set this value, but all too often, I forget to do it.  Therefore, it usually reads something like "Download_RPT_new_10-22-03," which is pretty ugly.  You can standardize report captions using some simple code.  Here's what you do:

       Add a label to your report named, for example, lblTitle
       Add this code to the report's module:

        Private Sub Report_Open(Cancel As Integer)
            ' Me refers to the container, the report itself.
            Me.Caption = Me.lblTitle.Caption
        End Sub
    
  • Standardize Report Headers
    Avoid having to modify dozens of reports when header information changes. Create a simple report with all the header information and drag-n-drop it in the Report Header of each of your reports. That way, if something changes, you only have to edit one report object, the header subform, and the changes propagate to all your reports.

    There is, however, a caveat: You MUST place your header controls in the subform's Report Header section. Since the subreport contains no data, the Page Header will never display, so controls there are ignored.

  • Standardize Report Footers
    Hey, footers have to be as easy as headers, right? Well, yes, they are, so long as you do not insert a Page X of Y control into it. To use paging with subforms, you need to understand how Access handles report pages. Let's begin by placing this code in the text box's ControlSource property:

      ="Page " & [Page] & " of " & [Pages]
      

    The problem is, again the subform has no pages, so it will always display 0 of 0. What you really want is to reference the page count of the report that contains the subform, its "Parent." So, add the word "Parent" to the code, like this:

      ="Page " & [Parent].[Page] & " of " & [Parent].[Pages]
      

    If you try this out, you'll see there is still a problem. Now the control displays 1 of 0. The subform does not know how many pages there are in the report because the Parent form doesn't know. In fact, Access reports never know how many pages they have, until you force them to calculate it. How do you do that? You insert a control that calls the [Pages] method, as we did in the subform.

    In other words, the [Pages] method forces the report to secretly format itself in hidden mode to calculate the total number of pages. Then, it returns to the beginning with this value safely stored in the [Pages] property and displays it as requested. So, in order to get the [Parent].[Pages] method to work in the subform, there must be one placed on the parent form. I know, it rather defeats the purpose, but that is how it works.

  • Draw a Box Around the Page
    Recently I was asked to draw a box around the entire page of a report. I must admit, I had to search Google for the code, but it is quite simple. Since you want to modify the page, it makes sense to put this code in the Report_Page() event.

      Private Sub Report_Page()
           On Error Resume Next
             ' Set Thickness and Border Style
             Me.DrawWidth = 6   ' larger number, thicker line
             Me.DrawStyle = 0   ' 0 to 6 = solid to invisible
    
             ' object.Line (x1, y1) - (x2,y2), color, [Box=B]
             Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), vbGreen, B
           End Sub
    
      
  • Toggling Row or Control Backcolors
    Another frequent request by users is to have report rows alternate backcolor, so they are easier to read. There are two ways to do this: change the detail section color or change the background color for each individual control in the row. Changing the detail secion color is less processing, but it is also easy to manipulate controls as a group. Consider this code, which demonstrates both methods:

           Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
           On Error Resume Next
    
             Const cYellow As Long = 10092543
             Const cwhite As Long = 16777215
             Const cPurple As Long = 16751052
    
             Dim ctl As Control
             Dim sec As Section
             Set sec = Me.Section("Detail")
    
             If sec.BackColor = cwhite Then 
                sec.BackColor = cYellow 
             Else 
                sec.BackColor = cwhite
             End If
    
             For Each ctl In sec.Controls
                If ctl.BackColor = cYellow Then
                   ctl.BackColor = cwhite
                Else
                   ctl.BackColor = cYellow
                End If
             Next
    
           End Sub 
    

    Play with the colors a little, using Purple for the controls instead of Yellow and you'll see what I mean.  It creates some very ugly reports, if you are not careful, but it is very powerful for those with a creative, right-brained programmer's eye.  Click the link below to see the output for the above report tricks.

Report Trick Example Report (Requires the Snapshot Viewer)

Go to page: 1  2  Next  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS Access Archives

Webcast: Five Virtualization Trends to Watch. Produced for HP, Citrix, and Intel.
Five Trends for Application Development. Download Your Complimentary Report. Exclusive. Act Now.
HP eBook: Using Business Service Management (BSM) to Manage Your Business Applications
Whitepaper: Enterprise Information Integration--Deployment Best Practices for Low-Cost Implementation
Flash Demo: Learn how IBM Information Server Blade is easy to manage, highly scalable and efficient.


Latest Forum Threads
MS Access Forum
Topic By Replies Updated
Export a report into excel Irina_5220 4 May 9th, 01:50 PM
Table Property Question barlowr70 0 May 6th, 10:51 AM
Compile MS Access Database samson 1 May 1st, 03:28 AM
How to connect MS-Access with c++ rockys111 0 April 30th, 01:36 AM







JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES