wordpress statistics
  • Today is Tuesday, May 22, 2012

9 Responses to “Working with Chart Object in VBA”

  1. I’m receiving a compile error “Expected variable or procedure, not project” that highlights “Reports” from the following that I copied/edited in my database (I have MS Access 2003). What am I missing? Do you know why I am receiving this error?
    ——————-
    Dim Rpt As Report
    Dim grphChart As Object
    Dim ReportName As String
    Dim ChartObjectName As String

    ReportName = “rptHours”
    ChartObjectName = “GraphHours”

    DoCmd.OpenReport ReportName, acViewDesign
    Set Rpt = Reports(ReportName)
    Set grphChart = Rpt(ChartObjectName)
    grphChart.Activate

  2. Ensure that you have not given the Global Module Name same as your Database, which I think it is now. The Procedure Name also should not have conflict with these names. You have to make change in one more of these values.

    Open the VBA Module. Select Tools – -> yourdatabasename Properties….

    Check the Project Name (which will be same as of your database name) and change it to something else than the Module Name.

    After changes re-compile the Code and Run the Program.

  3. Thanks so much. That worked!

  4. WannaKatana says:

    I get a compile error on msoGradientVertical and msoGradientHorizontal. One other example I saw used the Points object with these constants, not SeriesCollection object.

  5. Attach Microsoft Office Library File to your Project. Open any VBA Module. Select Tools – -> References and put a check mark on Microsoft Office 9.0 Library or equalent Version available on your machine.

    Refer the Post: http://www.msaccesstips.com/2006/09/command-button-animation/ for more details of attaching a Library File to your Project.

    Regards,

  6. Anonymous says:

    I am getting a type error at grphChart.Activate or grphChart.chartType = lngType
    I am using Access 2007. I have tried everything I can think of, but must be missing something simple. Enlightenment would be much appreciated!

  7. A sample database with the Chart Object examples will be prepared and added to the Download section shortly. You may download it. If you can leave your email address I shall forward a copy to you when it is ready.

    Regards,
    a.p.r. pillai

  8. Anonymous says:

    I am getting Type mismatch error when I try this and no changes appear to be made to the pie chart?
    I have MS Office Pro 2003 SP3, I created the chart myself and then created a module called Charts with your code pasted in. I ran from the immediate window…
    Thanks

  9. You may Download a Sample Database with running version of all examples of Charts from the following Link:
    http://www.msaccesstips.com/downloads/2008/06/workingwith_chartobject.shtml

    Regards,
    a.p.r. pillai

Leave a Reply

You must be logged in to post a comment.