Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Compact an Encrypted Microsoft Access Database

Status
Not open for further replies.

TinyNinja

Programmer
Oct 1, 2018
99
US
Hey VFP Community!

I wanted to post this since I finally figured it out and it might help someone else. I initially gave up on it but decided to come back to see if I could solve the issue of Compact&Repairing an encrypted Microsoft Access Database through VFP code. Here is my original thread on the topic. thread184-1791777 I would like to thank everyone who helped and lead me on the right path to solving it.

Here is the code.
Code:
lserver=[TestDB.accdb]
lbackdb=[Db_TestDB.accdb]
lcpass=[1234abcd]

oAccess = Createobject([Access.Application])
*!* oAccess.Visible=.T.
oAccess.Application.DBEngine.CompactDatabase(lserver, lbackdb, .F., .F., [highlight #FCAF3E]";pwd="+lcpass[/highlight])
oAccess.Quit()

Erase &lserver
Rename &lbackdb To &lserver

The missing part I found was I had to tell the DBEngine that the last part was the password with the ";pwd=1234abcd" in order for it to correctly open it.
My Microsoft database sits on a network drive so my code has the full path added to the server names which I removed from the code snippet above. If anyone does this just make sure there are no quotes in the lserver variable or else it will fail on you.

I hope this helps someone else out! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top