emorris1000
Registered User.
- Local time
- Today, 14:38
- Joined
- Feb 22, 2011
- Messages
- 125
Howdy all, 2 posts in one day, so you know I'm having fun.
I have a bunch of charts in my forms, and my boss wants to be able to adjust axes. I have added a context menu that brings up a little form and takes values that are then thrown into the graph by way of a function.
I've copied some stuff I found online here:
http://www.access-programmers.co.uk/forums/showthread.php?t=48641&highlight=Maximum+Scale
Here's the current code:
notes:
-ignore the global vars, they are a temporary measure.
-"Graph19" I know, not good. I never expected to call it in code though
, I'll fix it later
-the while loop keeps the rest of the code from running until the axes have been submitted.
Ok, so this code works for the x and y1 axes. I assumed that Axes(3) would iterate to the Y2 axis, it does not
I also found that after you change the axis the changes are persistent for the graph even upon repaint/requerying it. This is problematic and I need a way to set an On Load event that resets the graph to "autoscale"
So, what I really need is some decent documentation on this stuff, but I get the idea that since I am using generic object variables that may be tricky.
Lacking that, if someone knows how to access the Y2 axis, or if someone knows how to reset the axes to autoscale that would be keen.
Or, failing all that, if someone knows a good resource for graph management in access it would be appreciated.
ed: Actually could someone move this to the Modules/VBA section? Would probably work better there.
I have a bunch of charts in my forms, and my boss wants to be able to adjust axes. I have added a context menu that brings up a little form and takes values that are then thrown into the graph by way of a function.
I've copied some stuff I found online here:
http://www.access-programmers.co.uk/forums/showthread.php?t=48641&highlight=Maximum+Scale
Here's the current code:
Code:
Public Function AdjustTREFAxis()
'See form fTREFaxis
Dim objChart1 As Object
Dim objAxis1 As Object
DoCmd.OpenForm "fTREFAxis"
While IsOpen("fTREFAxis")
DoEvents
Wend
Set objChart1 = Forms![TGeneralChar]![SubTREFData].Form.Graph19.Object
'adjust x axis
Set objAxis1 = objChart1.Axes(1)
objAxis1.MinimumScale = TransferVar1 'TMin
objAxis1.MaximumScale = TransferVar2 'Tmax
'adjust y1 axis
Set objAxis1 = objChart1.Axes(2)
objAxis1.MinimumScale = TransferVar3 'ConcMin
objAxis1.MaximumScale = TransferVar4 'ConcMax
'adjust y2 axis, this doesn't work (Axes(3) doesn't seem to exist)
'
' Set objAxis1 = objChart1.Axes(3)
'
' objAxis1.MinimumScale = TransferVar5 'CumMin
' objAxis1.MaximumScale = TransferVar6 'CumMax
ClearGlobalVars
End Function
notes:
-ignore the global vars, they are a temporary measure.
-"Graph19" I know, not good. I never expected to call it in code though

-the while loop keeps the rest of the code from running until the axes have been submitted.
Ok, so this code works for the x and y1 axes. I assumed that Axes(3) would iterate to the Y2 axis, it does not

I also found that after you change the axis the changes are persistent for the graph even upon repaint/requerying it. This is problematic and I need a way to set an On Load event that resets the graph to "autoscale"
So, what I really need is some decent documentation on this stuff, but I get the idea that since I am using generic object variables that may be tricky.
Lacking that, if someone knows how to access the Y2 axis, or if someone knows how to reset the axes to autoscale that would be keen.
Or, failing all that, if someone knows a good resource for graph management in access it would be appreciated.
ed: Actually could someone move this to the Modules/VBA section? Would probably work better there.
Last edited: