Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...you guys have given us a way of asking a question and getting some very timely feedback from other users so we don't have to re-invent the wheel time and again..."

Geography

Where in the world do Tek-Tips members come from?

Report Labels Not Showing in 2010 but Were in 2003

shelby55 (TechnicalUser)
4 Jul 12 22:54
Hello

Thanks to MajP and Duane last year I was able to create a report made up of multiple subreports in Access 2003. It was more difficult than expected because the report had to be hardcoded for 12 months i.e. if the start date on the dialog box was 9/1/2011 then that was the first data in the report and the other months followed for a total of 12 months.

The parameters for the report were based on user input on a form (frmReportDialog).

On the On Open event of the subreport is the following code for the labels:

CODE

Private Sub Report_Open(Cancel As Integer)
  startDate = [Forms]![frmReportDialog]![txtStartDate]
    
  Me.RecordSource = "qryALCDays_C2"
  Me.lblM1.Caption = Format(startDate, "MMM")
  Me.lblM2.Caption = Format(addMonth(startDate, 1), "MMM")
  Me.lblM3.Caption = Format(addMonth(startDate, 2), "MMM")
  Me.lblM4.Caption = Format(addMonth(startDate, 3), "MMM")
  Me.lblM5.Caption = Format(addMonth(startDate, 4), "MMM")
  Me.lblM6.Caption = Format(addMonth(startDate, 5), "MMM")
  Me.lblM7.Caption = Format(addMonth(startDate, 6), "MMM")
  Me.lblM8.Caption = Format(addMonth(startDate, 7), "MMM")
  Me.lblM9.Caption = Format(addMonth(startDate, 8), "MMM")
  Me.lblM10.Caption = Format(addMonth(startDate, 9), "MMM")
  Me.lblM11.Caption = Format(addMonth(startDate, 10), "MMM")
  Me.lblM12.Caption = Format(addMonth(startDate, 11), "MMM")

End Sub 

Note that addMonth is a function:

CODE

Option Compare Database
Option Explicit
Public startDate As Date
Public Unit As String


Public Function getFirstOfMonth(dtmDate As Variant) As Variant
  If Not IsNull(dtmDate) Then
    getFirstOfMonth = DateSerial(Year(dtmDate), Month(dtmDate), 1)
  End If
End Function

Public Function addMonth(dtmDate As Variant, MonthsToAdd As Integer) As Variant
  Dim I As Integer
  If Not IsNull(dtmDate) Then
    addMonth = getFirstOfMonth(dtmDate)
    addMonth = DateAdd("M", MonthsToAdd, addMonth)
  End If
End Function


Public Function getStartDate()
Dim startDate As Date
startDate = Nz(Forms("frmReportDialog").txtStartDate, 0)
If startDate = 0 Then
    getStartDate = getFirstOfMonth(Date)
    Else
    getStartDate = getFirstOfMonth(startDate)
End If
End Function 

This worked well when the report was in Access 2003 but now there are two subreports that don't print these labels for all months. There is data for these months but the labels don't show up and it's not always the same month label that isn't visible.

Can anyone suggest what the issue might be or where I should look? I've already ensured that each subreport has the same properties and they are all the same so it isn't that. Thanks very much.
dhookom (Programmer)
5 Jul 12 1:02
I would place the code in the On Format event of the section containing the labels.

Duane
Hook'D on Access
MS Access MVP

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close