Change Graph Title using VBA (1 Viewer)

zooropa66

Registered User.
Local time
Today, 08:47
Joined
Nov 23, 2010
Messages
61
I have a graph called Graph7 on a form with the graph title set to XXX

I have the following code in the Forms on Load event

Code:
Me!Graph7.charttitle.Text = "AAA"

but when the Form loads the Title doesn't change to AAA

I've hunted numerous forums and tried the suggestions but to no avail

When I type Me.Graph7. (putting a . instead of a !) the little box of options pops up but there is no charttitle in the list

Thanks
 

zooropa66

Registered User.
Local time
Today, 08:47
Joined
Nov 23, 2010
Messages
61
Thanks for your reply.
That gives Run-time error 13 Type Mismatch
 

AccessMSSQL

Seasoned Programmer-ette
Local time
Today, 00:47
Joined
May 3, 2012
Messages
636
Are you using Microsoft Graph 12.0 object library?
 

zooropa66

Registered User.
Local time
Today, 08:47
Joined
Nov 23, 2010
Messages
61
The Graph has the following class > MSGraph.Chart.8 and I have selected
Microsoft Graph 11.0 Object Library in Tools > References
I'm using Access 2003
If I try typing out ch = Me.Graph7.Object.Application.Chart as per your suggestion, Intellisense works up to Object but typing the dot after Object produces no further Intellisense list
 

zooropa66

Registered User.
Local time
Today, 08:47
Joined
Nov 23, 2010
Messages
61
So my code so far is

Dim ch As Chart

Set ch = Me.Graph7.Object.Application.Chart

ch.ChartTitle.Text = "AAA"

gives Runtime Error 1004 > Unable to set the Text property of the Charttitle class
 

zooropa66

Registered User.
Local time
Today, 08:47
Joined
Nov 23, 2010
Messages
61
Hi AccessMSSQL,
The above code works just fine. The problem was that i was loading up the form containing the graph in design mode so that there was no data (via the graphs rowsource) on the graph. When i load up the form for real (rather than load it up in design mode) so that real data (bar charts) are shown, the title loads up with "AAA"
Of course, I'll be setting the title to a more meaningful variable later on. Thanks for all your help.
 

ChrisO

Registered User.
Local time
Today, 17:47
Joined
Apr 30, 2003
Messages
3,202
Also, something to try:-

Code:
Private Sub Form_Load()

    With Me.Graph7
        .HasTitle = True
        
        With .ChartTitle
            .Text = "AAA"
        End With
    End With

End Sub


More here.

Chris.
 

Users who are viewing this thread

Top Bottom