Chart Title

  • Thread starter Thread starter Jim Moore
  • Start date Start date
J

Jim Moore

I have set up a Pareto Chart on a form using Chart Wizard and would like to
set the title of the chart depending on the Query that populates the chart.

HTH Van T. Dinh stated that:
"You need to add the Microsoft Graphs Object Library into the References of
your database and use the ObjectBrowser to find it. Once you find it, use
the Help button in the ObjectBrowser to get to the right Help topic"

Can someone give me some insight into how to do this? Graph and ChartTitle
show up in the ObjectBrowser but I can't figure out how to tie this to an
object. On my form there are 3 objects (I think) - Form, Detail, and
OLEUnbound0.

Anything you can give me to get me started would be appreciated.

Jim Moore
 
(Please keep to the same thread)

For example:

Forms!YourForm!OLEUnbound0.ChartTitle = "ABC"
 
I got Run-time error '438': Object doesn't support this property of method
when using the example. I guess that I don't understand how to bind Graph
to the form. OLEUnbound0 properties show that OLE Class is "Microsoft Graph
Chart" and Class is MSGraph.Chart.8. I have gone to the Tools,References
menu option and checked "Microsoft Graph 10.0". Is there something else I
need to do???

Thanks,
Jim Moore
 
I assume you are using AXP and have Office XP installed on your PC???

Don't know why you got "8" there. Try changing it to 10. I post tomorrow
with the actual code I used in the database at work.
 
Yes AXP and Office XP on PC. I did previously change the 8 to 10 with no
effect. I thought that the 8 might be a clue as to why I am having the
problem. Do I need to Dim something as Microsoft Graph 10.0? Thank you for
checking your code at work.

Jim Moore
 
Code I used in the Form_Load Event of the Form that has
the Chart:

'****Code starts****
Private Sub Form_Load()
'================
' Form_frmGraph_LL.Form_Load
'--------
' Purpose:
'--------
' Notes :
'--------
' Parameters:
'
'--------
' Called Subs/Functions
' (none)
'--------
' Calling Subs/Functions
' (none)
'--------
' Returns:
' (none)
'--------
' Author : Van T. Dinh, Monday, 16 June 2003
'--------
' Revision History
' Monday, 16 June 2003 (VTD):
'================
On Error GoTo Form_Load_Err
Const QUERYNAME As String = "qqptGraph"

Dim objChart As Graph.Chart
Dim dblChart_Min As Double
Dim dblChart_Max As Double
Dim dblChart_Range As Double
Dim dblChart_ExRange As Double

Dim dblMin_RMin As Double
Dim dblMin_RMax As Double
Dim dblMin_SMin As Double
Dim dblMin_SMax As Double
Dim dblMax_RMin As Double
Dim dblMax_RMax As Double
Dim dblMax_SMin As Double
Dim dblMax_SMax As Double

Set objChart = Me.oleGraph.Object
With objChart
If Len(Trim(Me.OpenArgs & "")) > 3 Then
.HasTitle = True
.ChartTitle.Text = Nz(Me.OpenArgs, " ")
Else
.HasTitle = False
End If
If DCount("*", QUERYNAME) > 0 Then
dblMin_RMin = Nz(DMin("[Result Min]",
QUERYNAME, "[Result Min] Is Not Null"), 0)
dblMin_RMax = Nz(DMin("[Result Max]",
QUERYNAME, "[Result Max] Is Not Null"), 0)
dblMin_SMin = Nz(DMin("[Spec Min]",
QUERYNAME, "[Spec Min] Is Not Null"), 0)
dblMin_SMax = Nz(DMin("[Spec Max]",
QUERYNAME, "[Spec Max] Is Not Null"), 0)
dblMax_RMin = Nz(DMax("[Result Min]",
QUERYNAME, "[Result Min] Is Not Null"), 0)
dblMax_RMax = Nz(DMax("[Result Max]",
QUERYNAME, "[Result Max] Is Not Null"), 0)
dblMax_SMin = Nz(DMax("[Spec Min]",
QUERYNAME, "[Spec Min] Is Not Null"), 0)
dblMax_SMax = Nz(DMax("[Spec Max]",
QUERYNAME, "[Spec Max] Is Not Null"), 0)
dblChart_Min = fnZeroIgnoredMin(dblMin_RMin,
dblMin_RMax, dblMin_SMin, dblMin_SMax)
dblChart_Max = fnZeroIgnoredMax(dblMax_RMin,
dblMax_RMax, dblMax_SMin, dblMax_SMax)
dblChart_Range = Abs(dblChart_Max - dblChart_Min)

dblChart_Min = Round(dblChart_Min - 0.1 *
dblChart_Range, 1)
dblChart_Max = Round(dblChart_Max + 0.1 *
dblChart_Range, 1)
If (Abs(dblChart_Max - dblChart_Min) <= 4# * 10 ^ -
2) Then
dblChart_Max = dblChart_Min + 0.1
End If
dblChart_ExRange = dblChart_Max - dblChart_Min

.Axes(Graph.xlValue).MinimumScale = dblChart_Min
.Axes(Graph.xlValue).MaximumScale = dblChart_Max

If dblChart_ExRange > 4# Then
.Axes(Graph.xlValue).MajorUnit = Round
((dblChart_Max - dblChart_Min) / 4, 0)
ElseIf dblChart_ExRange > 0.4 Then
.Axes(Graph.xlValue).MajorUnit = Round
((dblChart_Max - dblChart_Min) / 4, 1)
Else
.Axes(Graph.xlValue).MajorUnit = Round
((dblChart_Max - dblChart_Min) / 4, 2)
End If

.Axes(Graph.xlValue).Crosses =
Graph.XlAxisCrosses.xlAxisCrossesCustom
.Axes(Graph.xlValue).CrossesAt = dblChart_Min
.Axes(Graph.xlCategory).Crosses = 1
End If
End With
Set objChart = Nothing

Form_Load_Exit:
Exit Sub

Form_Load_Err:
Select Case Err.Number
Case 0
Case Else
MsgBox "Error " & Err.Number & ": " &
Err.Description & vbCrLf & vbCrLf & _
"(Programmer's note: Form_frmGraph_LL.Form_Load)"
& vbCrLf, _
vbOKOnly + vbCritical, "Run-time Error!"
End Select
Resume Form_Load_Exit
End Sub
****Code ends****

Class is "MSGraph.Chart.10" in the Properties window of
the chart.

Microsoft Graph 10.0 Object Library is included in the
References.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top