Changing Axis scale of graph

Sniper-BoOyA-

Registered User.
Local time
Today, 10:34
Joined
Jun 15, 2010
Messages
204
Good Morning,

I have a mainform with a couple of subforms, and i can switch through them using tabs.

On one subform, i made a chart . Which works fine. Also added a button to refresh that chart if changes has been made (on other subforms).

What i would like to do now is to give the user the option to adjust the scaling of both axes. Whats the most efficient en easiest way to do it?

Ive searched the forums for the answer, and couldnt quite find what i needed.

Is it possible to make a combo box for lets say 'minimum value y-axis', and let the combobox.value be the mininum value of the chart?

I am new to the graphs and diagrams within Access, and i cant seem to figure this out.

Cheers!!
 
Last edited:
I just remembered, i had made an Excel file a couple years ago which had the possibility to manually change the scale of the axes.

Luckily i was able to find it (i think), and even though its VBA code is in Excel format id like to paste it. This is the VBA code of a form within Excel, where users can enter the Minimum Value of the scale, and the Unit-size.

Code:
Private Sub Aanpassen_Click()
Sheets("Invoer").Cells(16, 25) = xmin
Sheets("Invoer").Cells(16, 26) = eenh
Sheets("Invoer").Cells(21, 25) = ymin
Sheets("Invoer").Cells(21, 26) = yeenh
Sheets("Grafiek").Select
    ActiveSheet.ChartObjects("Grafiek 31").Activate
 
With ActiveChart.Axes(xlCategory)
        .MinimumScale = Sheets("Invoer").Range("Y16")
        .MaximumScale = Sheets("Invoer").Range("Y17")
        .MajorUnit = 1
        .CrossesAt = Sheets("Invoer").Range("Y18")
    End With
    ActiveChart.Axes(xlValue).Select
    With ActiveChart.Axes(xlValue)
        .MinimumScale = Sheets("Invoer").Range("Y21")
        .MaximumScale = Sheets("Invoer").Range("Y22")
        .MajorUnit = 10
    End With
Sheets("Grafiek").Range("N13").Select
Aanpasas.Hide
End Sub

From what ive seen the structure of the code isnt any different from the Access VBA, and im pretty sure i can use most of it. I just have to replace the references to cells (range) to an actuall combobox, and the reference to sheets to forms (only if i decide to make a seperate form for the comboboxes ofcourse)

Am i right? Or will this be a total mess ?
 
I just wanted to let you know ive figured it out when it comes to manually adjust the 2 axes of a graph.

I made 3 textboxes for each axis.

1. For giving the minimum scale
2. For giving the maximum scale
3. For giving the size of "steps" taken to get to max scale.

So lets say the minimum scale is 8, the maximum scale is 26, and the size of the unit is 1, then it will shot 8,9,10 ... 26 on the..

Then i added 2 button, one to apply the change for X- Axis, and one to apply the change to the Y-AXis.

Then on the click() event i added the following code :

Code:
Option Compare Database
Private Sub aanpassenx_Click()
 If Not Me![cboxmin] = Empty Then Me![Grafiek156].Axes(1).minimumscale = Me![cboxmin]
 If Not Me![cboxmax] = Empty Then Me![Grafiek156].Axes(1).maximumscale = Me![cboxmax]
 If Not Me![cboxeenh] = Empty Then Me![Grafiek156].Axes(1).majorunit = Me![cboxeenh]
 
 Me![Grafiek156].Requery
End Sub
Private Sub aanpasseny_Click()
If Not Me![cboxmin] = Empty Then Me![Grafiek156].Axes(2).minimumscale = Me![cboymin]
If Not Me![cboxmin] = Empty Then Me![Grafiek156].Axes(2).maximumscale = Me![cboymax]
If Not Me![cboxmin] = Empty Then Me![Grafiek156].Axes(2).majorunit = Me![cboyeenh]
Me![Grafiek156].Requery
End Sub
Private Sub Form_Open(Cancel As Integer)
    DoCmd.Maximize
End Sub
Private Sub Knop157_Click()
Me.Grafiek156.Requery
End Sub
 
Private Sub standaardx_Click()
End Sub

I do have one question though. I would like to add a button to activate the Auto scaling within Access, does anyone know the command for activating it?

Ive tried

Code:
[FONT=Times New Roman][FONT=Times New Roman]Me![Grafiek156].Axes(2).maximumscale = Auto[/FONT]
[/FONT]


But as you might have guessed, it doesnt work.
 
Thanks for the post. It helped me to figure out how to set the maximum value to a value stored in a table in my database.
 

Users who are viewing this thread

Back
Top Bottom