Timing a graph event (1 Viewer)

emorris1000

Registered User.
Local time
Yesterday, 17:04
Joined
Feb 22, 2011
Messages
125
I have been having some strange problems with graph errors that can be found here:

http://www.access-programmers.co.uk/forums/showthread.php?t=245033

(not necessary to read to help with problem, unless you want to try and tackle the underlying bug.)

Now, I've found a workaround that fixes the problems with the graphs (there are two graphs that cause problems). I simply have to wait until the graph has been drawn incorrectly and then I run this code:

Code:
Public Function FixGPCGraphs(GraphName As String)
 
Dim objChart As Object
Dim objAxis As Object
 
Select Case GraphName
Case "GPC1"
 
    Set objChart = Forms![TGeneralChar]![SubGPCData].Form.Graph18.Object
    Set objAxis = objChart.Axes(1)
     objChart.PlotOnX = 0
    objAxis.ScaleType = xlScaleLogarithmic
 
Case "GPC2"
    Set objChart = Forms![TGeneralChar]![SubGPCData].Form.Graph23.Object
        objChart.PlotOnX = 0
End Select
 
End Function

Right now this is called by a shortcut menu command. This ensures that the graph has been drawn. Also, if there is no data the subform these graphs are on is set to not be visible.

Now, I want to make this event driven so the user doesn't have to run the command each time they load this form. I tried using the "On Updated" event for one of the graphs, which would then call this code, but I got the following error:

"Automation Error
The caller is dispatching an asynchronous call and cannot make an outgoing call on behalf of this call"

This error seems to get called for a variety of lines surrounding this, seems to be anything that is pointed to the chart.

Anyways. I don't know what is causing this error. It seems like on of those "deep errors" that is beyond some simple coding. So what I need is some kind of delayed event that will ensure that the graph is fully loaded before it calls this event.

I've added .isvisible booleans to ensure the graph is visible before calling it, but this did nothing (error gets thrown at the boolean.)

Any thoughts?


Edit: Ok wow so seconds after I posted this I fixed it. I need to pre-type these problems in notepad and then look at the problem again before I post them.

Anyways, the fix was to move the FixGPCGraphs function call from an event tied to the GPC graphs to directly after I made the GPC graph page visible, which is an event in the parent form.

whelp. I'm feeling quite happy.

Still though, if anyone has any ideas how to fix the underlying graph problem (see link) let me know. I think it has to do with drawing log axes, but I'm not sure.
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 01:04
Joined
Feb 19, 2013
Messages
16,658
You can use the ontimer event. I've not tested this but this should work
  1. In your code where the graph is created put just before the call to create the graph: Me.timer =1000 'equivalent to 1 second, increase/decrease as required
  2. In the form On Timer Event put your call to FixGPCGraphs
  3. Finally modify your FixGPCGraphs function as follows
Code:
[COLOR=red]On Error Goto ExitFunction[/COLOR]
Select Case GraphName
... your code
 
End Select
[COLOR=red]Me.Timer=0[/COLOR]
 
[COLOR=red]:ExitFunction[/COLOR]
 

ur00361883

New member
Local time
Yesterday, 17:04
Joined
Dec 23, 2014
Messages
1
Hi CJ_London,

The Me.Timer=0 is not working as it is giving compilation error telling Timer member/method doesn't exist.

Can you please suggest an alternate way.

You can use the ontimer event. I've not tested this but this should work
  1. In your code where the graph is created put just before the call to create the graph: Me.timer =1000 'equivalent to 1 second, increase/decrease as required
  2. In the form On Timer Event put your call to FixGPCGraphs
  3. Finally modify your FixGPCGraphs function as follows
Code:
[COLOR=red]On Error Goto ExitFunction[/COLOR]
Select Case GraphName
... your code
 
End Select
[COLOR=red]Me.Timer=0[/COLOR]
 
[COLOR=red]:ExitFunction[/COLOR]
 

Users who are viewing this thread

Top Bottom