Error Message when running 'On Load' VBA code / Macro

ersocia

Aleph Null
Local time
Today, 19:27
Joined
Aug 10, 2012
Messages
41
i've entered some code in the 'On Load' portion of my main form, designed to pop up a confirmation dialog asking the user if they want to run a macro to update the DB's tables with current data from some linked tables. when loading the form, however, i get this message:

The expression On Load you entered as the event property setting produced the following error: A problem occurred while <My Database> was communicating with the OLE server or ActiveX Control.

* The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
* There may have been an error evaluating the function, event, or macro.

in addition, the "Show Help" button on this error message gives the following information:

This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired.

i don't really understand what this means, to be honest. the same code/macro combo worked perfectly fine on another form i created (and subsequently lost, which is why i'm recreating it). any help would be appreciated, and i can provide any additional information necessary.
 
Last edited:
da'ja'vue all over again.
My form just did the same thing. Did it several times, then 5 minutes later it worked with no code change. Five minutes late it did it again. It did this same thing last week right before I left for lunch. I didn't have time to look at it before lunch, after lunch ... and until today ... it didn't happen again.

It is probably some code or query in your Form Load or Form Open event for the form. In my case, I run a couple of functions that read a database and return some status.
That status determins in my case what or how a list box is populated.

If you have any filters in the query that opens a form, or opens a list box, - go into design mode and run the queries to see if they still work. If a field name in a table used in your form's query was renamed, it might result in this error.

Is your data and application all in one database, or do you have a split database? Is the data located on your local PC or on a network location? What about your application? Is it on your workstation, or are you running it from a network location.
 
It is probably some code or query in your Form Load or Form Open event for the form. In my case, I run a couple of functions that read a database and return some status.
That status determins in my case what or how a list box is populated.

If you have any filters in the query that opens a form, or opens a list box, - go into design mode and run the queries to see if they still work. If a field name in a table used in your form's query was renamed, it might result in this error.

out of all the forms in my database, this is the only one with any VBA code attached to it, and this form only has one piece of code, designed to simply, upon the form's loading, pop up a message box / confirmation dialog, with a simple Yes/No button scheme. 'Yes' will run a macro (which does in fact work when i run it manually; i just made sure of that a moment ago), and 'No' skips the macro and just opens the form.

upon loading the form, the message box does not pop up, and instead i get the described error message.

in short; no filters, no listbox, etc. - just a piece of code on a form, that does not do it's job for some reason.

Is your data and application all in one database, or do you have a split database? Is the data located on your local PC or on a network location? What about your application? Is it on your workstation, or are you running it from a network location.

the database is not split. it is all-in-one, so-to-speak.

the database is stored entirely on my local PC/workstation, however the copy of Access i am running is being run through a Citrix Presentation server. there are also several linked tables involved which are what the macro is designed to pull data from, in order to update the local tables. the linked tables are stored offsite, on our parent company's servers.

hopefully, this helps clarify my problem. if not, let me know and i will try to explain better.
 
Since this is a simple form - try these two err three things:
1. Open Access in Design mode (e.g. hold shift key down, don't run the startup form)
- Open this form from design view - does it open or still get this error?
2. Since you don't have a lot of code, viewing the vba code - in the code menu - choose Debug - Compile from the menu
3. From Code - menu Tools - References Is the VBA reference checked?
 
Since this is a simple form - try these two err three things:
1. Open Access in Design mode (e.g. hold shift key down, don't run the startup form)
- Open this form from design view - does it open or still get this error?
2. Since you don't have a lot of code, viewing the vba code - in the code menu - choose Debug - Compile from the menu
3. From Code - menu Tools - References Is the VBA reference checked?

i actually did all three of those things yesterday when the problem arose, but without incident. couldn't find any issues when doing so.

however, thanks to your PM, i've sorted the problem out.

for those interested in what fixed it, i simply created a new, blank database, and imported all tables/queries/reports/macros/forms from the problem database into the new one, and everything worked perfectly fine. it seems my original DB was corrupted somehow.

in any case, i sincerely thank you for the suggestion. :)
 
Glad your on your way forward.
Thanks for the followup. You might be surprised how many times this will help others in the future.
 
You might be surprised how many times this will help others in the future.

oh, i doubt i'd be surprised, as i'm usually more of a "search for an answer from somebody who already had this problem" kind of person, rather than a "post the question myself" kind. :P so i know the importance of posting the solution to your problem when you find it, because i'd only get more frustrated if i were looking for someone with a similar problem and found their thread, and they'd solved it without indicating how they did so.
 

Users who are viewing this thread

Back
Top Bottom