Solved

Ad Hoc Charts in Access

Posted on 1998-08-14
3
173 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now