run time error 91 - global variable (1 Viewer)

Wysy

Registered User.
Local time
Today, 09:24
Joined
Jul 5, 2015
Messages
333
Hi,
I am struggling with the following:
I have made two different application where i have used the same coding for having a dynamic customized ribbon. In both cases, the same procedure:
1. UsysRibbons table with ribbon code containing onLoad="onLoad" (same naming worked in both instances)
2. vba module with the following code:

Code:
Public sub onLoad(Ribbon as IRibbonUI)   
    set globIR=Ribbon
End sub

3. defining global variable to catch ribbon
Code:
Publis globIR as IRibbonUI

4. set a startup form for the application with onLoad and onClose event having globIR.Invalidate

This coding simply does not work in the third application though i have restarted my computer several times to restart access.
Upon starting the application before startup form loads run time error 91 appears. Clicking end program runs on correctly the customized ribbon function as designed.It seems to me that for some reason the startup form loads earlier than the global variable is set. I have check the perivous application what can be different but found no clue. Any idea?
thanks
Andrew
 

Wysy

Registered User.
Local time
Today, 09:24
Joined
Jul 5, 2015
Messages
333
sorry, obviously public in the code, just misspelled here.
 

Wysy

Registered User.
Local time
Today, 09:24
Joined
Jul 5, 2015
Messages
333
tried global: does not work. But what i do not understand is that why the same coding works in two other apps made on the same computer?
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:24
Joined
Sep 21, 2011
Messages
14,235
tried global: does not work. But what i do not understand is that why the same coding works in two other apps made on the same computer?
Given that you retyped the above instead of copying and pasting, did you do the same there.?
 

Wysy

Registered User.
Local time
Today, 09:24
Joined
Jul 5, 2015
Messages
333
with On Error Resume Next it is of course working. Is it possible that some onLoad event of the form contain this code but it is not visible in the VBA editor?
 

Wysy

Registered User.
Local time
Today, 09:24
Joined
Jul 5, 2015
Messages
333
with On Error Resume Next it is of course working. Is it possible that some onLoad event of the form contain this code but it is not visible in the VBA editor?
if i copy that given startup form, the code works. If i create a new startup form the code fails
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:24
Joined
Sep 21, 2011
Messages
14,235
I have never played around with Ribbons
Is that code in a startup form?, if so does that event even exist?, is that meant to be the form load?
 

Wysy

Registered User.
Local time
Today, 09:24
Joined
Jul 5, 2015
Messages
333
Yes it is the startup form and the code runs in onLoad event. Can it simply be that the onload event preceed the global variant set? And that this particular form is corrupted so the on error resume next code is not visible in the cba editor?
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:24
Joined
Sep 21, 2011
Messages
14,235
Really,
This is one of my form load events?
Code:
Private Sub Form_Load()
Dim ctr As Control
Dim frm As Form
Dim fc As FormatCondition

Set frm = Forms(Me.Name)
For Each ctr In frm.Controls
    Select Case ctr.ControlType
    Case acTextBox
    Debug.Print ctr.Name & ":" & ctr
    With ctr.FormatConditions
        With .Add(acExpression, acEqual, "[ID] = [Text3]")
    
            .BackColor = vbRed
        End With
    End With
    End Select
    
Next ctr
strSortCaption = "test sort string"
Debug.Print strSortCaption
End Sub
 

Users who are viewing this thread

Top Bottom