I created a graph and set its Size Mode property to Zoom.
I then added a three button option group (named frmSizer) and named the buttons Small, Med and Large, setting the respective values to Small = 1, Med = 2 and Large = 3. The values are arbitrary and can be whatever you find convenient but try 1,2 and 3 to begin with just to see what happens.
I next edited the forms code window as follows.
Option Compare Database
Option Explicit
'create two variables to hold the initial chart frame sizes.
Dim chtw As Double, chth As Double
Private Sub Form_Open(Cancel As Integer)
'get the initial chart frame dimensions
chtw = Me.Graph0.Width
chth = Me.Graph0.Height
End Sub
Private Sub frmSizer_AfterUpdate()
Me.Graph0.Width = chtw * frmSizer
Me.Graph0.Height = chth * frmSizer
End Sub
If you want you can type the intial graph size directly into the code but remember that in the Graph object's property window the Height and Width properties are given in centimetres or inches, whereas when you set these values in code the values must be in Twips. (567 twips per centimetre)
Taking my example the initial size of the graph was Height 5cm and Width 8cm.
To code this into the above I would enter:
Private Sub frmSizer_AfterUpdate()
Me.Graph0.Width = (8*567) * frmSizer
Me.Graph0.Height = (5*567) * frmSizer
End Sub
In this case there is no need for the two variables or the OnOpen event code to read the inital chart size.
[/color]
To code the form to automatically resize the chart you would need to obtain the number of x and y series elements displayed in the chart. E.g. suppose you had a chart showing monthly salaries for a group of people on a year to date basis. As the year progresses the number of months displayed increases and the number of people might increase.
By taking the number or people and the number of months these values could be used to calulate a suitable factor by which the graph height/width might be varied from the initial size. You could then place the resizing code in the form's Open Event so the graph is sized accordingly.