Protect the VBA Code
Thank you for taking the time to report an issue.
What's wrong... Please write below.
What is the best way to password protect the queries and VBA codes and still letting the users to use the database.
All of this is relatively simple, opening the document and populating the fields. The problem comes that you cannot populate the fields in a protected document, therefore, the document must be unprotected.
Then, because the control has passed to Word, I cannot figure out how to protect the form from my Access VBA code.
1. Password protect the database
2. Password protect the VB codes
3. Disable allowbypasskey
4. Make MDE file for versions 2003 and previous
a. the simplest way to protect is by password protecting
b. Allowbypasskey diabling is a protection done by vb code
c. by making the MDE file, the forms, report, dap, macro, and modules are locked thereby it cannot be opened for editing or for opening.
d. by making ULS, the objects are locked by access, I think this goes by code again and we setup its password.
Therefore, protecting the database objects were done thru coding matched by password. So therefore, maybe there is a way that we can make our own CODE to lock the database objects.And I think our gurus here in this forum might help us out with that code.Can we do this?
"The database cannot be opened because the VBA project contained in it cannot be read. The database can be opened only if the VBA project is first deleted. Deleting the VBA project removes all code form modules, forms and reports. You should back up your database before attempting to open the database and delete the VBA project."
This message appears every time a form with VBA code is opened, and every time I try to open the VBA editor. Of course I have a backup, however I rather not be forced to redo about 6 hours of work.
Looking across the internet it seams like quite a few people have had this problem, but no solutions. As far is I can tell, something in the VBA code has caused the database to become corrupted.
So my question is this, is there any way I could possibly recover at least some of the code? Could I somehow force Access to show me the code, even if a part of it is corrupt?
.Visible = False
.Workbooks.Open (outpath + outfile1)
.ActiveSheet.Protection.AllowEditRanges.Add Title:="myRange", Range:=Columns("O:P"), Password:="pass"
Fast forward a few hours, with no changes made, and the click of a command button is now shutting down Access. At the advice of a co-worker, I grabbed an MZ-Tool for VBA code clean up, and my eyes glazed over. I'm not even sure if this is the issue, or the correct way to resolve.
There is VBA code on of the forms (6 in total).
If I leave the code in VBA to export any county under 50,000KB, they all work perfect and the database does not corrupt. However, I have one relatively large PDF exports at 166,708KB.
As soon as I run the code to export this PDF file (and compact and repair my database thereafter) I get a error message upon re-opening the database stating that my VBA code is corrupt.
It then prompts me through some more error messages and it ends up erasing VBA code and any objects with VBA code attached. I'm just curious as to the reason why this file size is leading to a database corruption when it's coded into VBA.