In this blog post we will examine compilation and the effect it has on the code you write.
Compilation is the act of converting our human readable code ( VBA) into code the computer understands. It may also be that your code is compiled into an intermediary format often called object code. Either way, this just illustrates that our programs are actually just a human understandable representation of what we are telling our computers to do.
Generally you will not notice the compiler as these setting on the left are set to automatically compile during execution and whilst you type. |
You can explicitly force VBA IDE to compile all modules in the project.
Advanced Compilation and ACCDE
While compilation as described above allows your application to execute in a multiuser environment, it leaves all the form data, report data and VBA code available to be edited by anyone with a full installation of MS Access.
To combat this, we can create an ACCDE file in which all code has been compiled and cannot be altered. And when we say cannot we mean CANNOT! So, make a back-up of your database before converting so you always have the ability to alter the code you spent hours making.
Just to repeat:
MAKE A BACK UP OF YOUR DATABASE BEFORE DOING THIS OPERATION.
To Create an ACCDE file:
Why use an ACCDE file?
Creating an ACCDE file removes all design code so that Forms may only be opened in Form View and Modules cannot be debugged. So even if the SHIFT Key open method is used, no Forms, Reports or Code can be changed.
This is useful for the following situations:
- You don’t want users to change your forms, reports or code.
- It creates a more stable Access Database for multi-user environments.
- You want to protect your intellectual property.
- You want to publish your Access Database.
Multi-Users Environments
From first-hand experience in multi-user environments you are advised to only give end-users ACCDE or MDE files and split your back- and front-ends. Giving access to the ACCDB runs the possibility of inadvertent changes to form properties – e.g. when a user applies a filter to the form – and when saved this very well may corrupt your database.
Corrupt databases can be recovered but on the off-chance it is not possible it is not worth the risk. You’ll lose a day’s work at least (if not everything), if backups of your file server haven’t been kept.
Compilation is a concept worth understanding that will help you to distribute optimized databases to your clients.
Related Posts
Basic Tools for Writing Code Visual Basic EditorDebugging Visual Basic Editor
Immediate Window Visual Basic Editor
Opening The VBA Editor Visual Basic Editor
The VBA Editor Explained Visual Basic Editor
Visual Basic Editor Options Visual Basic Editor