Inserting Chart

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I copied some code and tried to customize it for a chart that I want in a
report.

The chart should have the months on top (column headings) and bars that will
span the Created date to the Due date. There should be a bar for each
record. The 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
'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 / 365
lngStart = DateDiff("d", #1/1/2001#, Me.[Created])
lngDuration = DateDiff("d", Me.[Created], Me.[Due Date])
'set the color of the bar based on a data value
Me.txtName.BackColor = Me.[Solicit Name]
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


Since this is existing code that I copied and trying to customize, I do not
know the function of:

Me.txtName.Left = (lngStart * dblFactor) + lngLMarg
Me.txtName.Width = (lngDuration * dblFactor)

It seems to crap out here.

Any help debugging this would be greatly appreciated. I cannot seem to find
the source code that I copied this from.

Thanks....
 
This code looks really familiar. txtName is the text box that creates the
horizontal bar.

This line sets the left position of the bar:
Me.txtName.Left = (lngStart * dblFactor) + lngLMarg

This line sets the width of the bar:
Me.txtName.Width = (lngDuration * dblFactor)

dblFactor should be the width of a single day in the time line.
 
Mark,

Have you looked at the next post to the newsgroup after yours? "Bar Graph On
Form" You both have the same goal.

Steve
(e-mail address removed)
 
They might be the same if they were both for either a report or form. This
question seems to be related to reports while the other is for a form. This
code will not work on a form.

--
Duane Hookom
Microsoft Access MVP


Steve said:
Mark,

Have you looked at the next post to the newsgroup after yours? "Bar Graph On
Form" You both have the same goal.

Steve
(e-mail address removed)


Mark said:
I copied some code and tried to customize it for a chart that I want in a
report.

The chart should have the months on top (column headings) and bars that
will
span the Created date to the Due date. There should be a bar for each
record. The 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
'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 / 365
lngStart = DateDiff("d", #1/1/2001#, Me.[Created])
lngDuration = DateDiff("d", Me.[Created], Me.[Due Date])
'set the color of the bar based on a data value
Me.txtName.BackColor = Me.[Solicit Name]
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


Since this is existing code that I copied and trying to customize, I do
not
know the function of:

Me.txtName.Left = (lngStart * dblFactor) + lngLMarg
Me.txtName.Width = (lngDuration * dblFactor)

It seems to crap out here.

Any help debugging this would be greatly appreciated. I cannot seem to
find
the source code that I copied this from.

Thanks....


.
 
Back
Top