views:

2284

answers:

7

I'm using Access 2003 on a duo-core machine with 4GB of RAM, running Windows XP (Service Pack 3) [5.1.2600]

Periodically, I get an error msg "There isn't enough memory to perform this operation. Close unneeded programs and try the operation again."

A check of Task Manager indicates that there is plenty of free memory. Closing other open programs makes no difference.

This happens sporadically, and under different circumstances: sometimes whilst saving Form design or VBA code changes, sometimes when several Forms are open and in use.

If attempting to save design changes, and this error occurs, the Access objects are corrupted and can't be recovered.

Any suggestions on what might be causing this would be very welcome.

MTIA

+3  A: 

Oh my.

I worked in a shop for many years that used Access as their platform of choice. The application eventually got so large that it began hitting an internal memory limitation of Access 2003. They began experiencing the exact same problem that you are having. As you have noticed, there is no external indication of memory problems when this happens.

The company talked at length with Microsoft about the problem, and I believe Microsoft eventually supplied them with a patch. So you might want to talk to Microsoft about this, if it sounds like a similar situation to what you are experiencing, as they may be able to supply you with the same patch.

Ultimately the long-term solution is to break the application into smaller pieces. Moving to Access 2007 didn't help; in fact, it made things worse because Access 2007 has more moving parts.

Robert Harvey
maxhugen
If you have an MSDN subscription, you have free incidents. In this particular case Microsoft should provide the patch for free.
Robert Harvey
+1  A: 

This is also the default error message when Access has no idea what the problem actually is. Now if your MDB is particularly large, say more than 800 forms and reports with modules then, yes the MDB could be too large although that gave you a message when you went to create MDEs. ACC2000: "Microsoft Access Was Unable to Create an MDE Database" Error Message

I have had this happen occasionally myself. And my current MDBs aren't quite that large. Note that compact and repair doesn't detect errors in objects other than tables, indexes or relationships. So importing into another MDB is the only way to correct these errors.

Are you working on this MDB over the network? That's about the only thing I can think of that might cause this problem.

Tony Toews
Hi Tony: the app is small. True, compact/repair is of no use, so I import all objects to a new mdb. The app is a FE/BE sitting on my local drive whilst developing.I've taken to backing up objects via the undocumented function Application.SaveAsText, and then Application.LoadFromText to recover the corrupted objects that could not be imported.It's laborious though, and Access's instability is worrying me, as it's happened to a user occasionally as well.
maxhugen
Max, there is a tool at one of the links at Corrupt Objects within a Corrupt Microsoft Access MDBhttp://www.granite.ab.ca/access/corruption/corruptobjects.htm which will do all the objects. I'd certainly review David's suggestions as well although I'm not sure if it's the VBA which is corrupt.
Tony Toews
Thanks Tony. I've a function that much the same as Arvin Meyer's. It dumps all objects into a time-stamped folder, as part of my backup strategies, and I use many times each day. I have exported a couple of corrupt forms, and note that the form decription is replaced by ???????? etc, but the VBA appears to be OK.
maxhugen
+4  A: 

The VBA project in your front end is likely corrupted. You need to rebuild it from scratch and then use proper Access coding practices:

  1. in VBE options, turn off COMPILE ON DEMAND (see Michael Kaplan's article on DECOMPILE for details of why).

  2. in VBE options, turn on REQUIRE VARIABLE DECLARATION.

  3. in the VBE, customize your toolbar so that the COMPILE button is easily accessible (it's on the Debug menu). I also recommend adding the CALL STACK button (from the VIEW menu), as it's handy for debugging errors in break mode. The point here is to make debugging and compiling as easy as possible.

  4. having set up your environment, go through all the modules in your newly recovered project and add OPTION EXPLICIT to the top of every module that lacks it. Then compile. You'll quickly find out where you have invalid code and you'll need to fix it.

  5. from now on, when programming, compile frequently, after every two or three lines of code. I probably compile my project 100 or more times a day when coding.

  6. periodically decompile your project and compact and recompile it. This will clean out any crud that accumulates during regular development.

These practices insure that the code in a non-corrupt project stays in as clean a condition as possible. It will do nothing to recover an already corrupted project.

In regard to how to rebuild the project, I think I'd go the drastic route of exporting all the objects with Application.SaveAsText and importing them into a new blank database with Application.LoadFromText. This is superior to simply importing from your existing corrupted front end because the import can import corrupt structures that won't survive a SaveAsText/LoadFromText cycle.

I program daily in Access, working with non-trivial apps that use lots of code, including plenty of standalone class modules. I have not lost an object to code corruption in over 5 years, and that was back in the day when I was still using A97.

David-W-Fenton
Thanks David. Re 1, what does that do? (not covered in Michael Kaplan's article) 2: always on. 3: I always compile after every code change. 4: always use this. 5: I also compile a lot. 6: I also regularly decompile/recompile. I too work daily with Access, for ~10 years. Haven't lost any code - I too have a lot of VBA modules/classes - but occasionally get a corrupted form or report. But recently I've been getting this 'memory' error. Today I lost most forms, and all reports! Fortunately, I had text backups of all objects from yesterday, and used LoadFromText to recover forms and reports.
maxhugen
The article explains why you don't want incremental compiles, because they increase the number of compilation levels that VBA has to keep track of. Explicit compiling is a complete compile. You might want to check the Help file article on COMPILE ON DEMAND (hit F1 while viewing the OPTION | GENERAL tab).
David-W-Fenton
A: 

I have encountered this problem many times and finally found a solution that worked. I don't know what causes the problem, but I do know how to solve it.

Usually the error occurs when you open a form. What you need to do is completely re-create that form. The easiest way to do so is to first export the form to a text file with the undocumented function Application.SaveAsText. Then you delete the form from your database and re-load it with Application.LoadFromText.

birger
+1  A: 

As I know that it's either forms or reports that most likely get corrupted, I created a new mdb, and only imported tables (attached), queries, scripts (one only), modules and menus. Then I used LoadFromText to import Forms and Reports via a function, and then did the usual decompile/compile and compact/repair etc.

So far, touch wood, I haven't had another crash in some days, so I'll probably stick with this recovery method.

Many thanks to all for your suggestions.

maxhugen
FWIW, I haven't had a serious crash for ~4wks since using LoadFromText, so the above-described backup and recovery methods using SaveAsText and LoadFromText appear to be most worthwhile.
maxhugen
A: 

Birger -- I just had this problem and used your suggested fix ... and it worked great. It was a biog form that I had worked a lot on, so I appreciated your suggestion a great deal. Thanks!

RKrumland
If you followed the practices I outlined in my answer, your chances of ever encountering a corrupt object are virtually nil.
David-W-Fenton
A: 

I have this problem now, however access crashes when I try and use saveAsText. Recreating forms is not an option, and this is occuring fairly frequently now resulting in lots of wasted time. Any ideas?

Daniel
Is it on every object, or just some? Does an import into a new database work?
David-W-Fenton