ironfelix717
Registered User.
- Local time
- Today, 16:58
- Joined
- Sep 20, 2019
- Messages
- 193
Hello,
Next up on unsolved mysteries: manipulating a chart object via code. I reached out to Access Forums about this issue with no success in solving: here
The problem at hand is manipulating a graph/chart via code. Specifically, manipulating the axes (scaling), plot area, other specific formatting. You know, things you should be able to do with VBA.
Confusions
The entire charting mechanism in Access is confusing. Its worth noting these confusions, which i'm sure i'm not alone on.
These sources of confusion might be... (i'm not requesting answers - though be my guest)
Prefaces
Problems
All i am trying to do is really adjust the max value and min value of the axes.
First and foremost, the newcomer would think maybe i can just use the control's properties. Surely the graph properties are in there to adjust the axes. Wrong. Just a bunch of rather useless properties besides 'Name', 'RowSourceType' etc, etc...
So... googling and googling. I made attempts at....
------------------------------------------------------------------------------------------
The mygraph object won't set because its invalid type - hence the documentation says '... on a REPORT'
Should a chart on a report be any different than one in a form? hmmm...
------------------------------------------------------------------------------------------
The closest i've gotten to manipulating a graph via code (besides frame height, etc) is the plot area. And i've used this...
The above lets me change the plot area. But has no property for Axes.
Furthermore - i have no intellisense for that object either, which is wonderful
(probably because its dimmed as 'Object')
Yes - MS Graph 16.0 reference is checked!
-----------------------------------------------------------------------------------------
So, i am hoping someone out there can provide some insight into whats going on here and why attempting to make chart adjustments via code has to be so difficult!
Thanks for your help!
Next up on unsolved mysteries: manipulating a chart object via code. I reached out to Access Forums about this issue with no success in solving: here
The problem at hand is manipulating a graph/chart via code. Specifically, manipulating the axes (scaling), plot area, other specific formatting. You know, things you should be able to do with VBA.
Confusions
The entire charting mechanism in Access is confusing. Its worth noting these confusions, which i'm sure i'm not alone on.
These sources of confusion might be... (i'm not requesting answers - though be my guest)
- insert "modern chart" vs "chart" - lets keep it simple and just call something a "chart". Are they different? Are they the same VBA object? Who even knows? From my experience the "modern" charts are awful and you can make a chart about as complex as a grade 3 student could.
- Microsoft Graph 16.0 Library VBA reference - None of the other controls need a specific reference, so why should a chart?
- Excel and Access seem to handle chart object completely differently - I could probably hop on Excel right now and do everything i need to do in VBA with a chart without any need for additional references.
- The documentation on the vba "chart object" references a chart on a REPORT - not a form.
Prefaces
- The problems i am facing are with Windows 10, Access 2019 x64
- The chart i reference is on a form, not a report
- There is a test file for example in the description
Problems
All i am trying to do is really adjust the max value and min value of the axes.
First and foremost, the newcomer would think maybe i can just use the control's properties. Surely the graph properties are in there to adjust the axes. Wrong. Just a bunch of rather useless properties besides 'Name', 'RowSourceType' etc, etc...
So... googling and googling. I made attempts at....
------------------------------------------------------------------------------------------
Code:
dim mygraph as Chart
set mygraph = me.controls("testgraph")
The mygraph object won't set because its invalid type - hence the documentation says '... on a REPORT'
Should a chart on a report be any different than one in a form? hmmm...
------------------------------------------------------------------------------------------
The closest i've gotten to manipulating a graph via code (besides frame height, etc) is the plot area. And i've used this...
Code:
dim obj as Object
Set obj = testgraph.Object.Application.Chart
obj.PlotArea.Height = 2 * 1440 'WORKS
obj.Axes(xlSeries, xlPrimary).MinimumScale = 7 'DOESNT WORK - CANT FIND 'AXES PROPERTY'
The above lets me change the plot area. But has no property for Axes.
Furthermore - i have no intellisense for that object either, which is wonderful

Yes - MS Graph 16.0 reference is checked!
-----------------------------------------------------------------------------------------
So, i am hoping someone out there can provide some insight into whats going on here and why attempting to make chart adjustments via code has to be so difficult!
Thanks for your help!
Attachments
Last edited: