dbTalk Databases Forums  

Getting To A "Chart" Object From VBA?

comp.databases.ms-access comp.databases.ms-access


Discuss Getting To A "Chart" Object From VBA? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
(PeteCresswell)
 
Posts: n/a

Default Getting To A "Chart" Object From VBA? - 03-31-2011 , 09:25 AM






Using Insert | Chart, I added a chart object to my report.

Ole Class = Microsoft Graph Chart
Class = MSGraph.Chart.8

But when I try to instantiate it in VBA, something is wrong:

------------------------------------------------
1002 Dim myChart As Object

1010 Set myChart = Me.chtWACQ

1020 With myChart
1021 .Activate
1022 .HasLegend = True
1999 End With
------------------------------------------------

Starting with line 1021, I get "Error# 438: Object doesn't
support this property or method".



OK, maybe we need the object within....

------------------------------------------------
1002 Dim myChart As Object

1010 Set myChart = Me.chtWACQ

1020 With myChart
1021 .Activate
1022 .HasLegend = True
1999 End With
------------------------------------------------

But now line 1010 throws "Error# 2771: The bound or unbound
object frame you tried to edit doesn't contain an OLE object.


I've been here before, decided it was hopeless, and reverted to
creating my charts on Excel spreadsheets.

But now it's crunch time: this thing just *has* tb on an MS
Access report. The .Activate and .HasLegend are just
placeholders to see if I've got the refs right. Once I can get
to the chart object, I will do a lot more.

Seems like I'm doing something dumb, but what?
--
PeteCresswell

Reply With Quote
  #2  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Getting To A "Chart" Object From VBA? - 03-31-2011 , 11:00 AM






(PeteCresswell) wrote:
Quote:
Using Insert | Chart, I added a chart object to my report.

Ole Class = Microsoft Graph Chart
Class = MSGraph.Chart.8

But when I try to instantiate it in VBA, something is wrong:

------------------------------------------------
1002 Dim myChart As Object

1010 Set myChart = Me.chtWACQ

1020 With myChart
1021 .Activate
1022 .HasLegend = True
1999 End With
------------------------------------------------

Starting with line 1021, I get "Error# 438: Object doesn't
support this property or method".



OK, maybe we need the object within....

------------------------------------------------
1002 Dim myChart As Object

1010 Set myChart = Me.chtWACQ

1020 With myChart
1021 .Activate
1022 .HasLegend = True
1999 End With
------------------------------------------------

I'm missing something. What, besides the line numbers, is the difference
between these two code snippets?


Quote:
But now line 1010 throws "Error# 2771: The bound or unbound
object frame you tried to edit doesn't contain an OLE object.


I've been here before, decided it was hopeless, and reverted to
creating my charts on Excel spreadsheets.

But now it's crunch time: this thing just *has* tb on an MS
Access report. The .Activate and .HasLegend are just
placeholders to see if I've got the refs right. Once I can get
to the chart object, I will do a lot more.

Seems like I'm doing something dumb, but what?
Failing to be explicit.
chtWACQ is an ObjectFrame object that has a property called Object that
contains a reference to the contained object. Try:

dim myChart as Chart
set myChart = me!chtWACQ.Object
etc.

Reply With Quote
  #3  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Getting To A "Chart" Object From VBA? - 03-31-2011 , 12:01 PM



Per Bob Barrows:
Quote:
I'm missing something. What, besides the line numbers, is the difference
between these two code snippets?

None. RCI on my part.

The second one shb, per your suggestion, "Set myChart -
me!chtWACQ.Object.

Quote:
Failing to be explicit.
chtWACQ is an ObjectFrame object that has a property called Object that
contains a reference to the contained object. Try:

dim myChart as Chart
set myChart = me!chtWACQ.Object
etc.
Intuitively, I get the "ObjectFrame" distinction, but the error
that Access throws when I do chtWACQ.Object suggests to me that
it does not contain an object.

i.e. "Error# 2771: The bound or unbound
object frame you tried to edit doesn't contain an OLE object."
--
PeteCresswell

Reply With Quote
  #4  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Getting To A "Chart" Object From VBA? - 03-31-2011 , 12:14 PM



(PeteCresswell) wrote:
Quote:
Per Bob Barrows:
I'm missing something. What, besides the line numbers, is the
difference between these two code snippets?

None. RCI on my part.

The second one shb, per your suggestion, "Set myChart -
me!chtWACQ.Object.

Failing to be explicit.
chtWACQ is an ObjectFrame object that has a property called Object
that contains a reference to the contained object. Try:

dim myChart as Chart
set myChart = me!chtWACQ.Object
etc.

Intuitively, I get the "ObjectFrame" distinction, but the error
that Access throws when I do chtWACQ.Object suggests to me that
it does not contain an object.

i.e. "Error# 2771: The bound or unbound
object frame you tried to edit doesn't contain an OLE object."
My attempts to reproduce your error have failed. All I can say is "It works
for me". Sorry

Reply With Quote
  #5  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Getting To A "Chart" Object From VBA? - 03-31-2011 , 12:27 PM



Per Bob Barrows:
Quote:
My attempts to reproduce your error have failed. All I can say is "It works
for me". Sorry
Thanks - actually that is helpful bc now I know that, at least,
the model that various web pages refer to actually works.

Gonna check my references next - make sure I've got the right
stuff behind them.

After that, on the assumption that I'm doing something dumb when
creating the chart object via the UI, I'll try to revert to 100%
VBA code... creating the object and all...
--
PeteCresswell

Reply With Quote
  #6  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Getting To A "Chart" Object From VBA? - 04-01-2011 , 02:58 PM



"(PeteCresswell)" <x@y.Invalid> wrote in
news:5439p61tasq2ru97iegpsi6gfhlhj56dgt (AT) 4ax (DOT) com:

Quote:
Using Insert | Chart, I added a chart object to my report.

Ole Class = Microsoft Graph Chart
Class = MSGraph.Chart.8

But when I try to instantiate it in VBA, something is wrong:

------------------------------------------------
1002 Dim myChart As Object

1010 Set myChart = Me.chtWACQ

1020 With myChart
1021 .Activate
1022 .HasLegend = True
1999 End With
------------------------------------------------

Starting with line 1021, I get "Error# 438: Object doesn't
support this property or method".
Where are you putting the code? Certain objects do not exist for
certain events. In general, I wouldn't expect this kind of thing to
work, since you can't do anything like this with subreports.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
  #7  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Getting To A "Chart" Object From VBA? - 04-02-2011 , 05:50 PM



Per David-W-Fenton:
Quote:
Where are you putting the code? Certain objects do not exist for
certain events. In general, I wouldn't expect this kind of thing to
work, since you can't do anything like this with subreports.
Report_Open().

I want to beautify the graph in a manner that does not seem tb
supported by the UI.

Specifically, I want to replace the numbered tick marks on the
Y-axis with labels like "AAA", "AA", "AA-"... and so-forth.

The values determining the height of the bars are actually
numerical representations of security ratings. 2.75 = AAA, 2.5
= AA, 2.25 = AA- and so-forth.

But the user doesn't know from the numbers. They are an
internal artifice used to create averages and weighted ratings.

All the user knows from are the alphabetic ratings like "AAA",
"AA", "AA-" and so-forth.
--
PeteCresswell

Reply With Quote
  #8  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Getting To A "Chart" Object From VBA? - 04-03-2011 , 10:35 AM



"(PeteCresswell)" <x@y.Invalid> wrote in
news:up9fp6thqq6n5laktdomvtl7u80hu5g5d3 (AT) 4ax (DOT) com:

Quote:
Per David-W-Fenton:
Where are you putting the code? Certain objects do not exist for
certain events. In general, I wouldn't expect this kind of thing
to work, since you can't do anything like this with subreports.

Report_Open().
Objects in the detail section of a report do not exist yet in the
report's Open event, if I'm not mistaken. It's like the difference
between OnOpen and OnLoad in a form.

If you want to make changes, you'll have to do them in one of the
events closer to the object, perhaps the OnFormat of the detail. I
don't see any alternatives, actually.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.