Question Undeclared Variable Does not throw error

speakers_86

Registered User.
Local time
Today, 02:38
Joined
May 17, 2007
Messages
1,919
I am confused as to how my db is working. I am using option explicit. In my error handling, I use a variable that I forgot to as Dim
Code:
ProcedureError as string
Even with the option explicit, it works fine. But I just copied the db (by way of right click), and all of a sudden this starts to error.

I'm worried that I am fighting corruption. I'm also concerned about my references. The references I have are
Code:
Visual Basic for Applications
Microsoft Access 14.0 Object Library
OLE Automation
and...Microsoft Access 14.0 Object Library Again!!!

Should that be there twice? The locations are different. The first one is at
C:\Program Files (x86)\Common Files\microsoft shared\VBA...(Cut-off)
the other
C:\Program Files(x86)\Common Files\Microsoft Shared\Off...(Cut-off)

I remember putting the second one there myself troubleshooting why I got an error declaring gobjRibbon as RibbonUI, but I did not realize that I had it twice. Having the second one there allows the ribbon to work, but it seems wrong to me.
 
Do you Debug > Compile often?
Do you Compact & Repair every so often?
Do you have a timer running?
 
Yes I compile often. Everytime I want to check and see if I screwed up.

I don't compact and repair as often as I should. Mainly if I think I encountered some kind of issue, or if I am near completion.

Yes, there is a timer running. I don't see how the timer matters as I have identical code in 2 different db, one errors, one does not.
 
Compact & Repair often. This process gets rid of cached or redundant items or objects.
Stop the timer.

If you perform both steps it should be back to normal.
 
Because I did not declare the variable, I would expect it to error. So I went to the db that is not throwing errors, compiled, turned off the timer, and still no errors.

edit- with Option Explicit, this errors in one db but not the other:
Code:
Public Sub SetAccessControlBox(booEnableAccessControlBox As Boolean)
    Dim ErrorName As String
    ErrorName = "SetAccessControlBox_Error"
    Dim ExitThisSub As String
    ExitThisSub = "Exit_" & ErrorName
    ProcedureError = "mdlHideAccessControlBox-SetAccessControlBox"
    Call TrackUsage("mdlHideAccessControlBox-SetAccessControlBox")
    If Nz(g_booEnableErrorHandling, -1) = -1 Then On Error GoTo ErrorName
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 'code here
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ExitThisSub:
    Exit Sub
ErrorName:
    Call LogError(Err.Number, Err.Description, ProcedureError)
    Resume ExitThisSub
End Sub

The variable in question is ProcedureError.
 
Yes I know, you already mentioned this in your first post.

From what you just explained you didn't Debug > Compile in the right manner. I did actually say, turn off the timer, Save, Compact & Repair, Debug > Compile.

In that order.
 
Then it may be declared in the declarations of the module itself
 
Then it may be declared in the declarations of the module itself
It may even be declared in a Standard Module. Search for that text in the entire project using Find Whole Word or Pattern Matching.
 
Oh my god, I was freaking out. Okay, the issue was that in the db that was throwing the error, I had actually combined 2 different db, but there was a mdlErrorHandling, and a mdlErrorTrapping. ProcedureError was declared in both as a public. When I first encountered this issue, the first thing I did was search for this variable as a public, but I didn't use the right terms.

As always, thanks for your help vbaInet.

edit- This is why I normally store all of my globals in mdlGlobals. For some reason I made an exception here.
 
It was a combined effort from spikepl and myself really. I just thought that you really haven't declared the variable since you were adamant that you hadn't. ;)
 
vbaInet: thx for the spurs, but I really do not get upset for not getting exhaustive thank offerings.

You do one heck of job, especially dealing with cases straining the patience of mere mortals, and I just throw in a penny here and there, so the distribution of the verbal goats, chickens, oxen and virgins is quite fair :D
 
Lol does kind of offerings would have been much more substantial :D
 

Users who are viewing this thread

Back
Top Bottom