Solved

Ad Hoc Charts in Access

Posted on 1998-08-14
3
179 Views
Last Modified: 2006-11-17
I'm supposed to generate reports and charts based on a variety of factors selected from a form. Kind of like a report/chart wizard. I think I can do the reports, but not the charts. Do I use MS Graph or the MSChart ActiveX control? Can it be generated/modified dynamically with VBA?
0
Comment
Question by:dwbrown
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
ramrom earned 100 total points
ID: 1959212
MS Graph is pretty versatile. If you have Office 97 Professional, there is a help file on the CD:\valupack\morehelp\vbagrp8.hlp. It isn't a vrey good help file. Here is some sample code I'm using to drive it (from FoxPro), but the translation to VBA is straightforward:

set gr = me!graph.graph.application '  where graph is the control name.
with gr
  with .datasheet ' holds the axis labels, legend and data
    .range("B:Z").delete   ' remove initial set of data
    .range("2:12").delete
  end with
  with .chart
    .charttype = xlBarClustered
    .hastitle = .t.
    with .charttitle
      .font.size = 12
      .font.bold = .f.
      .text = rpt_name + ' ' + dtoc(date()) + ' ' + sub_title
    end with
    .hastitle = .f.
    with .axes(2)
      .hastitle = .t.
      with .axistitle
        .font.size = 10
        .font.bold = .f.
        .orientation = 0
        .text = "% Proficient or Count"
      end with
      .maximumscale = 100
      .ticklabels.font.bold = .f.
      .ticklabels.font.size = 10
    end with
    if somecondition
      with .legend
        .font.size = 10
        .font.bold = .f.
      end with
    else
      .haslegend = .f.
    endif

Loading data (from an array) :

for ds_row = 2 to n_cols + 1
  gr.datasheet.cells(ds_row, ds_col) = graph_data(DataRow, ds_row - 1)
next j

Setting x axis label:
gr.datasheet.cells(1, ds_col) = "First Trail"

Setting legendl:
gr.datasheet.cells(2, 1) = "Boys"
gr.datasheet.cells(3, 1) = "Girls"

In FoxPro
  .t. = true
  .f. = false
  endif = end if
  if stmt does not have then

Hope this helps
0
 
LVL 17

Expert Comment

by:ramrom
ID: 1959213
BTW dtoc() is a FoxPro date to character conversion function.
0
 

Author Comment

by:dwbrown
ID: 1959214
thanks for your answer, before I accept it, which i will, I have an additional question or 3. I have tried just setting the HasTitle property, just to establish communication with the graph, via VBA, with no success. Have you done this in Access? I assume you put the control on a form or report first? Is this an ActiveX control? Maybe I need to re-register it. I can insert the control on a form but can't access it in code. thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question