Here’re the steps to password protect just the VBA code for an Access database, but not the rest of the database.
Steps: In Access, press ALT+F11 to open VBA editor, On Tools menu, select <Database Name> Properties…, On Protection tab, select Lock project for viewing check box, Enter and confirm a password, Click OK, and then close and reopen database.
Next time you go to view VBA code, you’ll be prompted for password.
Note there’re a lot of free or inexpensive tools that allow you to “recover” lost passwords, so protecting your VBA by using this procedure shouldn’t be considered a fool-proof security method. However, it’s a good way to keep people from accidentally changing the code.
A more robust way to protect your VBA code is to convert the database to an .accde or .mde file, read here.