The object doesn't contain the Automation Object 'LocalVars' error

zappyton

Registered User.
Local time
Today, 00:16
Joined
Jul 4, 2014
Messages
12
Hi,

I have a database in Access 2000 format which has been being used for years now, and it's just developed a problem. I have one datasheet form, which has a tick box field. When this field changes, a macro runs which updates another form, opens a third form for the user to enter some data into, and them refreshes the initial form, as only the unticked data needs to be on there.

It works fine on my computer, running access 2010 windows 8.1, but on two other computers in the office, both running Access 2007, one on windows XP, one on vista, throw the same error when the tick box is checked "The object doesn't contain the Automation Object 'LocalVars'". I don't have any object with that name, which rules out most of the internet help on other threads.

Can anybody help? Please?
 
LocalVars is used in a macro to get/let the value of a variable. The variable is created by an action called SetLocalVar. Check in one of your macros.
 
OK, I have some Set Value steps in the macro, but why would they error on one computer, and not the other? And what does that error actually mean?
 
If I remember correctly LocalVars is only accessible from within the macro it was created. If you want a global macro variable use the SetTempVar action instead.

And about why it errors and one and not the other is a misnomer.
 
I don't use any variables within the macro, it just copies the data from one form to another, and then opens an update query.

And I don't understand, in what way is it a misnomer?
 
LocalVars must have been referenced somewhere.

Sorry I'm typing from my phone, it's supposed to read mystery.
 
OK, mystery makes more sense.

I don't understand where it could be coming from. Could it be something to do with the two different version of Access? And I've done the same thing on those computers previously.
 
OK, I'll give that I try. Unfortunately, the file is on the network at work, so I'll have to do it when I get in tomorrow.
 
OK... I tried converting to VBA, and now it errors on the original computer with "The expression On Click you entered as the event property setting produced the following error: Ambiguous name detected: Done_Click."
 
I did say do this on a backup copy so I hope you've done that.

The error simply means that there's another function or macro with the same name. So copy the macro to a new database and convert it there.
 
Right, I found the duplicated module, and deleted it, and then it worked on the original computer, but still throws the same error on the other computers. Here's the code it executes.

Code:
Option Compare Database

'------------------------------------------------------------
' Done_Click
'
'------------------------------------------------------------
Private Sub Done_Click()
On Error GoTo Done_Click_Err

    DoCmd.Echo False, ""
    DoCmd.Hourglass True
    If (Forms![Maintenance Schedule]!MaintanceRequired = "Never going to happen PAT") Then
        DoCmd.OpenForm "HistoryPAT", acNormal, "", "", , acHidden
        DoCmd.GoToRecord acForm, "HistoryPAT", acNewRec
        Forms!HistoryPAT!EquipmentID = Forms![Maintenance Schedule]!EquipmentID
        Forms!HistoryPAT!MaintenanceDone = Forms![Maintenance Schedule]!MaintanceRequired
        DoCmd.Close acForm, "Maintenance Schedule"
        DoCmd.OpenQuery "Update Date Query", acViewNormal, acEdit
        DoCmd.OpenForm "Maintenance Schedule", acFormDS, "", "", , acNormal
        DoCmd.OpenForm "HistoryPAT", acNormal, "", "", , acNormal
        DoCmd.GoToRecord , "", acLast
        DoCmd.Maximize
    Else
        DoCmd.OpenForm "History", acNormal, "", "", , acHidden
        DoCmd.GoToRecord acForm, "History", acNewRec
        Forms!History!EquipmentID = Forms![Maintenance Schedule]!EquipmentID
        Forms!History!MaintenanceDone = Forms![Maintenance Schedule]!MaintanceRequired
        DoCmd.Close acForm, "Maintenance Schedule"
        DoCmd.OpenQuery "Update Date Query", acViewNormal, acEdit
        DoCmd.OpenForm "Maintenance Schedule", acFormDS, "", "", , acNormal
        DoCmd.OpenForm "History", acNormal, "", "", , acNormal
        DoCmd.GoToRecord , "", acLast
        DoCmd.Maximize
    End If


Done_Click_Exit:
    Exit Sub

Done_Click_Err:
    MsgBox Error$
    Resume Done_Click_Exit

End Sub
 
The same error meaning the "LocalVars" error? In that case this is not the macro or code that is causing the problem. You need to look for a macro that's using SetLocalVars.
 
Yes, it is the LocalVars error again. But that's the thing, this is the only macro which runs when you start click the box. Unless an update query can have LocalVars? Sorry if I'm not making much sense, I'm totally self taught.
 
Last edited:
But it's not the only macro in your database right?
 
No, but it is the only macro which is running. Plus,is the function SetLocalVars? Because I don't remember hearing of the function before, so I think it is unlikely I'm using it. I'll have a look through them though.
 
Someone on your form (or the form itself) could be calling or using another form, control of field that calls a macro using this action or is trying to refer to "LocalVars" in code.

Also check the Control Source and Row Source of your controls too.
 
Would LocalVars appear in the macro somewhere, or do I have to convert everything to code first?
 
It would and it may also appear in your Control/Row Sources.
 

Users who are viewing this thread

Back
Top Bottom