Force MS Graph to retrieve records

I

Ian

I have a microsoft chart embedded in a form, and supply
the SQL string for its rowsource property from VBA.

After setting this I want to go on and perform other
manipulations on the chart, which depend on the data
contained in the chart. The problem is that the chart
takes a finite time to retrieve all its records after
setting the rowsource, during which the VBA code is still
executing and so gets incorrect information on the number
of series and points when it interrogates the incompletely
updated chart.

Is there a way to force Graph to update completely before
continuing with VBA execution, or it there a way in VBA to
test whether the chart has completed updating?

At the moment the only thing I can do is set a timer to
trigger the further manipulation of the chart after a
decent period, which allows the chart to finish updating.
Not very satisfactory!

Thanks

Ian
 
V

Van T. Dinh

Any reason why you cannot set the RowSource correctly first then open the
Chart so that on open, the Chart has the correct RowSource?

I did something similar a while a go and I used a saved Query (but changes
required every time I open the Chart) as the RowSource for the Chart. When
I needed to open the Chart, I used the QueryDef Object in VBA code to modify
the saved Query (so that the Query returns the Records I wanted for the
Chart). After that, I open the Form that contains the Chart and the Chart
has the correct RowSource on opening!
 
I

ian

Any reason why you cannot set the RowSource correctly
first then open the
Chart so that on open, the Chart has the correct
RowSource?

I want users to be able to change the contents of the
graph, repeatedly, by clicking on a series of options and
by setting criteria that determine the records that are
retrieved. Unfortunately this means that I don't know what
the 'correct' rowsource is until the user makes a choice
and so i have to be able to handle it in VBA. I could set
the rowsource using the query def as you suggest, but that
would mean repaetedly closing and reopening the Chart form
every time the user made a change - and also I'd still
want to run code to label the points when the form opened,
which would still run the risk of the rowsource query not
having completed first.
Cheers
Ian
 
V

Van T. Dinh

That was basically my requirements also.

I open a Form "frmPreChart" so that the user can select different options.
Once, he/she selects the required options and click the "Show Chart"
CommandButton, the CommandButton_Click Event modify the SQL String of the
saved Query to select the required Records according to the user's selected
options and THEN open the Form with the Chart which uses the (modified)
saved Query as the RowSource.

Basically, the saved Query is just a name so that I can set it as the
RowSource for the Chart but every time the Chart is required, the
CommandButton_Click Event changes the SQL String of the Query substantially.

If the user wants to change the options, he/she has to come back to the
frmPreChart to select different options.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top