Dec 1 2011, 06:20 AM
Hi - we run an access application in our office. The database is split with the back end on a machine that also has a front end. There are two other machines with front ends - three users who access and manipulate the back end. When I make changes to the front end code from time to time, I merely change the name of the file to accdr, and this .accdr file replaces the previous .accdr file on the three machines. Even though the system runs smoothly, I'm wondering if should I be compiling my code when I make changes? I've read references to the fact that if code isn't compiled, it has to be compiled each time an uncompiled procedure is run. Is that true? Some advice from someone in the know would be great, thanks.
Dec 1 2011, 06:34 AM
By compiling, do you mean compiling the modules,as in during code developement (debug -> compile all modules), or compile as in convert the finished file to an accde file.
ompiling the code itself, that's an absolute must. If you don't do that (extremely) regularly during your code writing, you'll wind up with corruption eventually. Always compile the code before saving the module, exiting access, or running any code (anywhere) in the project. Compile whenever you think you're at a state with the code where it should compile (no design-time errors).
HAs for the file, this one is less of a "must", but still not a bad practice. However, using an accdr rather than accde isn't going to bother anything (although, I should note that I don't use runtime access very often).
Dec 1 2011, 07:00 AM
Great - thanks for the advice. I'll have a look for the compile button next time I'm tweaking some code!
Dec 1 2011, 07:08 AM
Office VBA has a "feature" that allows us to run the code without explicitly compiling it first. In my opinion, they should have left this out. When you write code, there's a number of different layers to your code... the plaintext version you see on your screen, cached copies of that, copies of that converted to something readable by the machine, etc etc etc.
When you write code, VBA automatically updates *some* of this, thus allowing the code to be run seemingly without compiling. At this point there's conflicting versions of the code, which is ok in theory (VBA sorts it out), but leaves a lot of room for error. Compiling through the menu command (or ribbon command on '07 I suppose?) syncs these different versions and smooths out any differences.
You may notice sometimes that if you're debugging and stepping through the code, and you change a thing or two in debug mode (which is techincally allowed), when you exit debug mode those changes are lost. This is the same principle: when in debug mode it keeps seperate copies of your code; one to run, one to edit, etc, but sometimes gets confused. The solution there: don't edit in debug mode.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here