P
Plumdodge
Access 2000 SP3
I am using the code from Dev Ashish from
http://www.mvps.org/access/reports/rpt0018.htm
I have modified (or tried to) in order to fit a fixed business week with the
start date monday and end date Friday of the current week. This will be used
to show the current workload for staff. Some project could start prior to the
week or end after the week but I'd like to see them represnted graphicly by
the timeline.
The two problems I am having and can not figure out are:
1) The size of the boxGrowForDate does not change. There must be something I
have altered to cause this, but for the life of me I can't figure out why?
2) How can I make it use the starting date of Monday of the current instead
of the actaul start date when it precedes monday of this week? I think I must
need IIF somewhere but I am unsure where.
Here is the code behind it, any ideas or suggestions are welcome and if
someone knows the definition of Twips I'd be quite interested too! Thanks,
The error trapping isn't done yet so it's real simple
Option Compare Database
Option Explicit
Private mdatEarliest As Date
Private mdatLatest As Date
Private mintDayDiff As Integer
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo Optout
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single
On Error Resume Next
'Set Scale
Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff
'Deal with dates which are populated'
If Not IsNull(Me.T_Start_Date) And Not IsNull(Me.T_Stop_Date) Then
Me.boxGrowForDate.Visible = True
Me.lblTotalDays.Visible = True
'intStartDayDiff = Distance from Start
'intDayDiff = Day length of entry
intStartDayDiff = Abs(DateDiff("d", Me.T_Start_Date, mdatEarliest))
intDayDiff = Abs(DateDiff("d", Me.T_Stop_Date, Me.T_Start_Date))
If intStartDayDiff = 0 Then intStartDayDiff = 1
With Me.boxGrowForDate
.left = Me.boxMaxDays.left + (intStartDayDiff * sngFactor)
.Width = intDayDiff * sngFactor
End With
Me.lblTotalDays.left = Me.boxGrowForDate.left
Me.lblTotalDays.Caption = intDayDiff & " Day(s)"
Else
Me.boxGrowForDate.Visible = False
Me.lblTotalDays.Visible = False
End If
Me.int = sngFactor
Me.sng = intDayDiff
Optexit:
Exit Sub
Optout:
MsgBox "Can't display"
Resume Optexit
End Sub
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Optout
'Set Start Date to Monday of this week
mdatEarliest = Date - Weekday(Date, vbMonday) + 1
'Set End Date to Friday of this week
mdatLatest = Date - Weekday(Date, vbFriday) + 8
'Get Scale
mintDayDiff = DateDiff("d", mdatEarliest, mdatLatest)
'Slap some values on the labels
Me.txtMinStartDate.Caption = Format(mdatEarliest, "mm/dd/yyyy")
Me.day2.Caption = Format(mdatEarliest + 1, "mm/dd/yyyy")
Me.Day3.Caption = Format(mdatEarliest + 2, "mm/dd/yyyy")
Me.day4.Caption = Format(mdatEarliest + 3, "mm/dd/yyyy")
Me.txtMaxEndDate.Caption = Format(mdatLatest, "mm/dd/yyyy")
Optexit:
Exit Sub
Optout:
MsgBox "Can't display"
Resume Optexit
End Sub
I am using the code from Dev Ashish from
http://www.mvps.org/access/reports/rpt0018.htm
I have modified (or tried to) in order to fit a fixed business week with the
start date monday and end date Friday of the current week. This will be used
to show the current workload for staff. Some project could start prior to the
week or end after the week but I'd like to see them represnted graphicly by
the timeline.
The two problems I am having and can not figure out are:
1) The size of the boxGrowForDate does not change. There must be something I
have altered to cause this, but for the life of me I can't figure out why?
2) How can I make it use the starting date of Monday of the current instead
of the actaul start date when it precedes monday of this week? I think I must
need IIF somewhere but I am unsure where.
Here is the code behind it, any ideas or suggestions are welcome and if
someone knows the definition of Twips I'd be quite interested too! Thanks,
The error trapping isn't done yet so it's real simple
Option Compare Database
Option Explicit
Private mdatEarliest As Date
Private mdatLatest As Date
Private mintDayDiff As Integer
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo Optout
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single
On Error Resume Next
'Set Scale
Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff
'Deal with dates which are populated'
If Not IsNull(Me.T_Start_Date) And Not IsNull(Me.T_Stop_Date) Then
Me.boxGrowForDate.Visible = True
Me.lblTotalDays.Visible = True
'intStartDayDiff = Distance from Start
'intDayDiff = Day length of entry
intStartDayDiff = Abs(DateDiff("d", Me.T_Start_Date, mdatEarliest))
intDayDiff = Abs(DateDiff("d", Me.T_Stop_Date, Me.T_Start_Date))
If intStartDayDiff = 0 Then intStartDayDiff = 1
With Me.boxGrowForDate
.left = Me.boxMaxDays.left + (intStartDayDiff * sngFactor)
.Width = intDayDiff * sngFactor
End With
Me.lblTotalDays.left = Me.boxGrowForDate.left
Me.lblTotalDays.Caption = intDayDiff & " Day(s)"
Else
Me.boxGrowForDate.Visible = False
Me.lblTotalDays.Visible = False
End If
Me.int = sngFactor
Me.sng = intDayDiff
Optexit:
Exit Sub
Optout:
MsgBox "Can't display"
Resume Optexit
End Sub
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Optout
'Set Start Date to Monday of this week
mdatEarliest = Date - Weekday(Date, vbMonday) + 1
'Set End Date to Friday of this week
mdatLatest = Date - Weekday(Date, vbFriday) + 8
'Get Scale
mintDayDiff = DateDiff("d", mdatEarliest, mdatLatest)
'Slap some values on the labels
Me.txtMinStartDate.Caption = Format(mdatEarliest, "mm/dd/yyyy")
Me.day2.Caption = Format(mdatEarliest + 1, "mm/dd/yyyy")
Me.Day3.Caption = Format(mdatEarliest + 2, "mm/dd/yyyy")
Me.day4.Caption = Format(mdatEarliest + 3, "mm/dd/yyyy")
Me.txtMaxEndDate.Caption = Format(mdatLatest, "mm/dd/yyyy")
Optexit:
Exit Sub
Optout:
MsgBox "Can't display"
Resume Optexit
End Sub