Monthly gantt chart with days

R

Ryan Addams

Hi

I have utilised Duane Hookom's gantt chart report from
http://www.access.hookom.net/Samples/CalendarReports.zip

Then I decided rather than to view it as a year, to view it as a
month, and I was wondering if there was a way to get access to show a
grid for dates on it? the current code is:

Option Compare Database
Option Explicit

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim lngDuration As Long 'days of tour
Dim lngStart As Long 'start date of tour
Dim lngLMarg As Long
Dim dblFactor As Double
Dim X As Double
'put a line control in your page header that starts 1/1 and goes
to 12/31
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 31
lngStart = DateDiff("d", Me.Monthname, Me.[Start Date])
lngDuration = DateDiff("d", Me.[Start Date], Me.[End Date])
'set the color of the bar based on a data value
Me.txtName.BackColor = Me.TaskColour
Me.txtName.Width = 10 'avoid the positioning error
Me.txtName.Left = (lngStart * dblFactor) + lngLMarg
Me.txtName.Width = (lngDuration * dblFactor)
Me.MoveLayout = False
End Sub

Private Sub Report_Close()
DoCmd.Restore
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
End Sub


Any help would be appreciated.
 
D

Duane Hookom

Why not just use the Line control? You could place 31 vertical lines in the
group footer or detail section (I think).

You could also use the Line method of the report to draw vertical lines. It
would require setting up a loop from 0 to 31 and multiplying the loop number
times dblFactor and adding lngLMarg to get the X value of the line. The
problem with the line method is that it would draw on top of the boxes if
they cross dates. This could be resolved by creating a group header that is
the same height as the detail and footer section. Then use code like:
Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
Dim lngLMarg As Long
Dim dblFactor As Double
Dim intDay As Integer
Dim dblLeft As Double
'put a line control in your page header that starts 1/1 and goes to 12/31
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 31
For intDay = 0 To 31
dblLeft = intDay * dblFactor + lngLMarg
Me.Line (dblLeft, 0)-Step(0, Me.Height)
Next
Me.MoveLayout = False
End Sub
 
R

Rowan Adams

Thankyou very much, you have been an incredible help.

Why not just use the Line control? You could place 31 vertical lines in the
group footer or detail section (I think).

You could also use the Line method of the report to draw vertical lines. It
would require setting up a loop from 0 to 31 and multiplying the loop number
times dblFactor and adding lngLMarg to get the X value of the line. The
problem with the line method is that it would draw on top of the boxes if
they cross dates. This could be resolved by creating a group header that is
the same height as the detail and footer section. Then use code like:
Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
    Dim lngLMarg As Long
    Dim dblFactor As Double
    Dim intDay As Integer
    Dim dblLeft As Double
    'put a line control in your page header that starts 1/1 and goes to 12/31
    lngLMarg = Me.boxTimeLine.Left
    dblFactor = Me.boxTimeLine.Width / 31
    For intDay = 0 To 31
        dblLeft = intDay * dblFactor + lngLMarg
        Me.Line (dblLeft, 0)-Step(0, Me.Height)
    Next
    Me.MoveLayout = False
End Sub

--
Duane Hookom
Microsoft Access MVP

Ryan Addams said:
I have utilised Duane Hookom's gantt chart report from
http://www.access.hookom.net/Samples/CalendarReports.zip
Then I decided rather than to view it as a year, to view it as a
month, and I was wondering if there was a way to get access to show a
grid for dates on it? the current code is:
Option Compare Database
Option Explicit
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim lngDuration As Long 'days of tour
    Dim lngStart As Long  'start date of tour
    Dim lngLMarg As Long
    Dim dblFactor As Double
    Dim X As Double
    'put a line control in your page header that starts 1/1 and goes
to 12/31
    lngLMarg = Me.boxTimeLine.Left
    dblFactor = Me.boxTimeLine.Width / 31
    lngStart = DateDiff("d", Me.Monthname, Me.[Start Date])
    lngDuration = DateDiff("d", Me.[Start Date], Me.[End Date])
    'set the color of the bar based on a data value
    Me.txtName.BackColor = Me.TaskColour
    Me.txtName.Width = 10  'avoid the positioning error
    Me.txtName.Left = (lngStart * dblFactor) + lngLMarg
    Me.txtName.Width = (lngDuration * dblFactor)
    Me.MoveLayout = False
End Sub
Private Sub Report_Close()
    DoCmd.Restore
End Sub
Private Sub Report_Open(Cancel As Integer)
    DoCmd.Maximize
End Sub
Any help would be appreciated.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top