Problem Running VBA Code after Reloading Operating System.

Posted on 2011-05-09
Last Modified: 2012-05-11
Windows 7 Home Premium
Access 2003

I have recently re formatted and reinstalled office 2003 and since then I get the following error when ever i attempt to run any vba code i.e. to close a form, to open another form, to save a record, or simply go to a new record.

The expression On Click you entered as the event property setting produced the following error: A problem occured while Microsoft Office Access was communicating with the OLE server or ActiveX Control.

this is an example of vba code i have on a button to save current record and go to a new record.

Private Sub Command12_Click()
If Me.Dirty Then Me.Dirty = False
DoCmd.GoToRecord , , acNewRec

End Sub
Question by:mickeyshelley1
    LVL 56

    Expert Comment

    by:Jim Dettman (Microsoft MVP/ EE MVE)
    You have a broken VBA reference.  Open a module, click tools/references and then check any un-checked reference.  Close the DB and Access, re-open and uncheck the reference you just checked.

    Then do a compile.  If no errors, you should be set.  If not, you either:

    a. need to add a reference that the app needs
    b. Need to re-register DAO if your using it.
    c.  Need to either decompile or create a fresh DB as you might have some VBA project corruption.

    Bounce back and let me know...

    Author Comment

    The database in question works fine on others computers, it worked fine on this computer until it crashed and I had to do a reinstall. I checked the references and didn’t find any “missing” so I am at a loss..
    LVL 56

    Expert Comment

    by:Jim Dettman (Microsoft MVP/ EE MVE)
    Well your using DAO, so go ahead and re-register that (won't hurt):

    1. Drop to a command prompt.
    2. CD to Windows\system32
    3. Type

      Regsvr32 "<path to the DAO DLL>"

    usually it's

    regsvr32 "c:\program files\common files\microsoft shared\dao\dao360.dll"

      But check the path in the reference dialog.

     Also, did you follow the reference refresh procedure I gave in my first comment?

    LVL 84

    Accepted Solution

    If that doesn't work, you might try a repair or reinstall of Access/Office.

    Also - does this occur on other databases, or just this one? If it's ONLY this one, you might need to perform maintenance on the database (i.e. compact, or move everything to a new, blank database).

    Author Closing Comment

    I moved everything into a new blank database which corrected the issue.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now