Skip to main content Pricing for individuals For families For single users For premium users For students Learn more Pricing for business For small business For schools For government Pricing for enterprise For enterprise For frontline workers For nonprofits For government Meet Copilot Copilot Chat AI Agents Daily Prompt Guide Plans and pricing Microsoft Teams Word Excel PowerPoint Outlook OneDrive SharePoint Planner See all apps and services Microsoft Office Windows 365 Microsoft Viva Microsoft Edge Microsoft Agent 365 Plans and pricing Learn to use Copilot Copilot learning center Cost savings Accounts and billing FAQ Setup and install Templates Training What's new Microsoft Frontier Program Microsoft 365 Roadmap Microsoft 365 Blog Small Business Resource Center Self-help resources Billing support Community Contact Microsoft Support Self-help resources Admin self-help Support plans Find a partner Contact Sales Community Self-help resources Educator Center Request support Contact Microsoft Support Community Become a partner Partner resources See all support Try for free

Try Microsoft 365 Copilot

Available on desktop and mobile devices

A question came in recently regarding whether you can password protect just the VBA code for an Access database, but not the rest of the database. The answer is yes!

Here’s how to do it:

  1. In Access, press ALT+F11 to open the VBA editor.
  2. On the Tools menu, select <Database Name> Properties
  3. On the Protection tab, select the Lock project for viewing check box.
  4. Enter and confirm a password.
  5. Click OK, and then close and reopen the database.

Next time you go to view the VBA code, you’ll be prompted for the password.

Note that there are a lot of free or inexpensive tools that allow you to ‘recover’ lost passwords, so protecting your VBA by using this procedure should not be considered a fool-proof security method. However, it’s a good way to keep people from accidentally changing the code.

Thanks to Kevin Bell on the Access team for his help with this tip, and be sure to keep sending your favorite tips to Mike and Chris at accpower@microsoft.com!