Solved

Dates change on Report

Posted on 2014-01-14
3
250 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
  • 2
3 Comments
 
LVL 24

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now