Search code examples
ms-accessformsms-access-2007subform

MS Access 2003/2007 - Chart Object on a sub form, not loading when parent forms load


SO I have a subform, that simply has one chart object on it. Its small, and this is the only purpose of this sub. Then I have about 10 forms that each have a sub windows with this form as it's child. I use a UNION query to show the current balance of 10 accounts on each form with this chart for comparative purposes. Everything works fine except for one small thing...

when you open any of these forms, you have to take your mouse over to the actual sub window and click inside of it to get the chart to show. once you do it works fine, on any and all forms, but this same issue if recurring on all these forms as well, so I am sure I am missing something here??

Any ideas about this one?

thanks Justin


Solution

  • I think you can work this out by not using a subform, but rather a chart control directly inserted in the form. I know it can be a headache to design a chart control in every form, but by doing it, you can control directly the data source of the chart independently from any other form.

    Example:

    I will suppose that you need to update the chart after updating a text box (txtExample). You can alter the data source of the control usint the afterUpdate event:

    Private Sub txtExample_AfterUpdate()
      chart1.RowSource = "SELECT ... FROM ..." 
      chart1.Requery
    End Sub
    

    The RowSource property of the chart object will be altered and updated every time the value of the text box is updated.

    Hope this works for you