views:

895

answers:

2

I'm trying to use the built in Make ACCDE functionality in access to make a standalone application that interfaces to an SQL-Server 2008 back end. When I run the Make ACCDE I receive an error that states that too many TableID references are being used (the limit is stated to be around 2048).

Through trial and error (deleting forms until it compiles) I've discovered which form is causing the issues. It seems to compile if I delete all the VBA code from the form.

I was wondering if anyone has run into this problem before and if there is a specific issue that causes it? I've run into this problem a few times now and it's a real pain to go through my code deleting half of it to find where the error is coming from.

A: 

I've occasionally seen similar errors. I'd suggest importing all your objects into a new ACCDB. Compact & Repairing only cleans up tables and indexes and doesn't do much in the way of corruption diagnosis or cleanup for the other objects.

If you do have it isolated to one particular form try doing a copy and paste on the form. This should be enough for Access to save a clean copy of the form.

Next time you encounter this though could you record the exact error message including the number and email me at tony at granite.ab.ca. I'd like to add this to my list of such errors for my corruptions web page as this appears to be an Access 2007 specific message.

Tony Toews
@Tony There isn't any error number associated. It just gives you a generic error text. I have since fixed the problem and it seems that it was caused by a reference to some missing resource in the VB code. The only way I was able to track it down was through a brute force delete everything and add stuff in until it breaks approach.
Rister
Do you mean an actual missing reference, or something corrupted in the code that was still pointing to something that was no longer there? In the former case, checking the REFERENCES list on the TOOLS menu should reveal whatever is missing, and in the latter case, a compile (after a decompile) should flush out exactly what line of code is causing the problem. I try to minimize the number of references and use late binding whenever possible.
David-W-Fenton
Rister, I was looking for the TableID references message. Uusually that's a sign you haven't compiled your code but I see you have it solved. What exactly do you mean by missing resource in the VB code?
Tony Toews
+1  A: 

For future coding, you should make sure you follow good coding practices:

  1. in VBE options, turn off COMPILE ON DEMAND and make sure REQUIRE VARIABLE DECLARATION is turned ON (this will cause new modules to be created with OPTION EXPLICIT by default).

  2. add the compile button to your toolbar in the VBE so its easily accessible. When coding, hit the compile button after every few lines of code (and SAVE after each compile). This will prevent you from writing too many uncompilable lines of code, so it will be easier to fix them to be compilable.

  3. on a regular basis, make a backup of your database and decompile and recompile it. This will clean out any crud that has accumulated in the compiled p-code (decompile strips all the compiled p-code and leaves only the canonical code text) and can flush out compile errors that had previously been hidden by corrupted p-code.

By following these best practices, you will hardly ever encounter code corruption.

David-W-Fenton
How do you add the compile button to the VB editor? I looked and it doesn't seem to exist on any of the toolbars - just on the debug menu.
Rister
Right click the toolbar, choose Customize. In the dialog of commands, select the DEBUG menu, then scroll down until the COMPILE button is visible on the right. Then drag that button and drop it on the toolbar where you'd like to be. I always put it at the far right. I also add the CALL STACK button (it's under the VIEW menu), as I like being able to navigate it when troubleshooting in break mode.
David-W-Fenton