I have a XY-Chart graph in a form and the graph row source
will depend on the SQL statement.

Private Sub OK_Click()

On Error GoTo OK_fix

Dim i as integer
Dim MySQL as string

[MyGraph].RowSource = MySQL

For i = 1 to no_of_records
[MyGraph].SeriesCollection(i).size = i * 3
Next i

OK_Exit:
Exit Sub

OK_fix:
Resume OK_Exit

End Sub


I always have error whenever the previous no_of_records is
smaller than the current one. It always says "Cannot
access the series collection property". My guess is
because MySQL takes a while to run, so when it tries to
access the series collection, that particular series
collection has not been created.

If I click on the OK button once more, it always works
fine, but I don't think my user is interested in doing it.
I also try calling OK_Click again during error handler, it
does not work. Any suggestion ? Thanks.


NB: no_of_records = no of series collection
mySQL changes depending on user's choice

I guess what I wanna do is making sure the graph is
finished refreshed before running the for loop.