Solved

Dates change on Report

Posted on 2014-01-14
3
255 Views
Last Modified: 2014-01-15
I have a database and table where the dates will change and need the report to reflect the different dates when the report is ran.  If I create a report with Titles once it seems would need to rebuild the report each time for the new dates.   Is there a way not to have to do this.  I am thinking to build a table of the dates and add text fileds to the report to refer to dates but I am also using a crosstab query with the date ranges and would need to line the columns up to the text fields.

May look like this one month with dates as headings

11/30/13                      12/31/13                   1/31/14
1111                                   5555                           abc
nbc
458



and this the next month


2/28/14                        3/40/14                        4/30/14



My question is whether I can build one report or if a new report will need to be designed each time.
Database7.zip
0
Comment
Question by:leezac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
chaau earned 500 total points
ID: 39780712
It is very easy to do. First of all, rename the Labels Name property for the Column Headings to Label1, Label2, Label3. Rename the TextBoxes Name property for the columns to Col1, Col2, Col3.
Then, create the event procedure for report's On Open event. Put this code into the procedure:
Private Sub Report_Open(Cancel As Integer)
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tb_temp_Crosstab")
    
    Me.Label1.Caption = rs.Fields(2).Name
    Me.Label2.Caption = rs.Fields(3).Name
    Me.Label3.Caption = rs.Fields(4).Name
    
    Me.Col1.ControlSource = rs.Fields(2).Name
    Me.Col2.ControlSource = rs.Fields(3).Name
    Me.Col3.ControlSource = rs.Fields(4).Name
    rs.Close
End Sub

Open in new window

I have attached the database where I have modified some dates
Database7.mdb
0
 

Author Closing Comment

by:leezac
ID: 39780764
Thanks - that worked great.
0
 

Author Comment

by:leezac
ID: 39782535
Thanks - I am working on testing all the answers.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question