Run time error 91 Object variable or With block variable not set RRS feed

  • Question

  •       I've never used VBA before but since a program that I currently work has built-in VBA Code Interface I have no other choice.


        My program is relatively simple and it is  the example in the tutorial of the program that I work with (IGSS):


    Dim atm As IGSSATOM

    Private Sub IGSSDiagram_OnOpen()
    DiagramTimerTick = 10000 'set timer to come every second (1000 milli sec)
    'Set atm = OnlineDB.Objects("temp1_1").Atoms("value")
    Set atm = Configuration.OnlineDB.Objects("temp1_1").Atoms("value")
    atm.Value = 17
    count = 0
    End Sub
    Private Sub IGSSDiagram_OnClose()
    Set atm = Nothing
    DiagramTimerTick = 0
    End Sub

    Private Sub IGSSDiagram_OnTimer()
        atm.Value = atm.Value + 10
     End Sub

      I get this error at the line  atm.Value = atm.Value + 10. I guess the error is related to the fact that the variable atm is set in another procedure, but since the variable is global it shouldn't matter.   I tried using the with statement but it doesn't help. 

    Thursday, June 13, 2013 2:03 PM

All replies

  • Has the sub "IGSSDiagram_OnOpen" actually run? If it has not, atm will not be initialized. The On_Open may need to go into a specific module - similar to how the codemodule behind Excel's Thisworkbook object works.

    Try adding a line to IGSSDiagram_OnOpen:

    Msgbox "I have run!"

    to confirm that it runs when your open IGSS.

    Thursday, June 13, 2013 2:42 PM