Thanks to Duane Hookom's example database I was able to set up a simple timeline report that worked great.
However, when I modified the code so that I would use it for a series of dates attached to one project (each project can have up to 3 spans using 6 total data fields from an external source), the code doesn't work when the values for the dates are 'null' and I think I am now going in a circle as far as testing different adjustments.
Here is the modified code I am using - I have taken out the 'If' lines to get it to work for projects with all dates filled in - but it gives an idea of what I am trying to do. When I leave those lines in the project title is listed, but doesn't position itself where it should and isn't the correct color - so I am guessing that the code isn't working at all.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim lngStart1 As Long 'start date of review process
Dim lngDuration1 As Long 'days of review process
Dim lngStart2 As Long 'start date of review process
Dim lngDuration2 As Long 'days of review process
Dim lngStart3 As Long 'start date of review process
Dim lngDuration3 As Long 'days of review process
Dim lngLMarg As Long
Dim dblFactor As Double
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 520
'If Me.Receipt_Date1_Adjusted <> Null Then
lngStart1 = DateDiff("d", [Forms]![Date Span]![Start Date], Me.Receipt_Date1_Adjusted)
lngDuration1 = DateDiff("d", Me.Receipt_Date1_Adjusted, Me.Review_Date1_Adjusted)
Me.TimelineBar.BackColor = Me.DivisionColor
Me.TimelineBar.Width = 10 'to avoid the positioning error
Me.TimelineBar.Left = (lngStart1 * dblFactor) + lngLMarg
Me.TimelineBar.Width = (lngDuration1 * dblFactor)
'End If
'If Me.Receipt_Date2_Adjusted <> Null Then
lngStart2 = DateDiff("d", [Forms]![Date Span]![Start Date], Me.Receipt_Date2_Adjusted)
lngDuration2 = DateDiff("d", Me.Receipt_Date2_Adjusted, Me.Review_Date2_Adjusted)
Me.TimelineBar2.BackColor = Me.DivisionColor
Me.TimelineBar2.Width = 10 'to avoid the positioning error
Me.TimelineBar2.Left = (lngStart2 * dblFactor) + lngLMarg
Me.TimelineBar2.Width = (lngDuration2 * dblFactor)
'End If
'If Me.Receipt_Date3_Adjusted <> Null Then
lngStart3 = DateDiff("d", [Forms]![Date Span]![Start Date], Me.Receipt_Date3_Adjusted)
lngDuration3 = DateDiff("d", Me.Receipt_Date3_Adjusted, Me.Review_Date3_Adjusted)
Me.TimelineBar3.BackColor = Me.DivisionColor
Me.TimelineBar3.Width = 10 'to avoid the positioning error
Me.TimelineBar3.Left = (lngStart3 * dblFactor) + lngLMarg
Me.TimelineBar3.Width = (lngDuration3 * dblFactor)
'End If
Me.MoveLayout = False
End Sub
I have tried adding an 'Else' coding line, but that doesn't help. Any ideas would be great!
However, when I modified the code so that I would use it for a series of dates attached to one project (each project can have up to 3 spans using 6 total data fields from an external source), the code doesn't work when the values for the dates are 'null' and I think I am now going in a circle as far as testing different adjustments.
Here is the modified code I am using - I have taken out the 'If' lines to get it to work for projects with all dates filled in - but it gives an idea of what I am trying to do. When I leave those lines in the project title is listed, but doesn't position itself where it should and isn't the correct color - so I am guessing that the code isn't working at all.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim lngStart1 As Long 'start date of review process
Dim lngDuration1 As Long 'days of review process
Dim lngStart2 As Long 'start date of review process
Dim lngDuration2 As Long 'days of review process
Dim lngStart3 As Long 'start date of review process
Dim lngDuration3 As Long 'days of review process
Dim lngLMarg As Long
Dim dblFactor As Double
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 520
'If Me.Receipt_Date1_Adjusted <> Null Then
lngStart1 = DateDiff("d", [Forms]![Date Span]![Start Date], Me.Receipt_Date1_Adjusted)
lngDuration1 = DateDiff("d", Me.Receipt_Date1_Adjusted, Me.Review_Date1_Adjusted)
Me.TimelineBar.BackColor = Me.DivisionColor
Me.TimelineBar.Width = 10 'to avoid the positioning error
Me.TimelineBar.Left = (lngStart1 * dblFactor) + lngLMarg
Me.TimelineBar.Width = (lngDuration1 * dblFactor)
'End If
'If Me.Receipt_Date2_Adjusted <> Null Then
lngStart2 = DateDiff("d", [Forms]![Date Span]![Start Date], Me.Receipt_Date2_Adjusted)
lngDuration2 = DateDiff("d", Me.Receipt_Date2_Adjusted, Me.Review_Date2_Adjusted)
Me.TimelineBar2.BackColor = Me.DivisionColor
Me.TimelineBar2.Width = 10 'to avoid the positioning error
Me.TimelineBar2.Left = (lngStart2 * dblFactor) + lngLMarg
Me.TimelineBar2.Width = (lngDuration2 * dblFactor)
'End If
'If Me.Receipt_Date3_Adjusted <> Null Then
lngStart3 = DateDiff("d", [Forms]![Date Span]![Start Date], Me.Receipt_Date3_Adjusted)
lngDuration3 = DateDiff("d", Me.Receipt_Date3_Adjusted, Me.Review_Date3_Adjusted)
Me.TimelineBar3.BackColor = Me.DivisionColor
Me.TimelineBar3.Width = 10 'to avoid the positioning error
Me.TimelineBar3.Left = (lngStart3 * dblFactor) + lngLMarg
Me.TimelineBar3.Width = (lngDuration3 * dblFactor)
'End If
Me.MoveLayout = False
End Sub
I have tried adding an 'Else' coding line, but that doesn't help. Any ideas would be great!