Compacting a BE with password protection

Instead of running the  code below on run prompt to compile the BE , is there no way we can run it from a form either when opening a start up form? We are given a facility to compact the FE on close .

msaccess.exe /pwd yourpassword /compact "C:\Users\chris.hankwembo\Desktop\HqInfor Premier_Mu.accdb"

I may be wrong but the code above appear to be opening my BE even if it is encrypted and password protected, if I'm right, is there a way to help user run this code at start up form?

A sketch will be highly appreciated.

Regards

Chris
LVL 3
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
I believe the syntax is:

msaccess.exe databasefile /pwd yourpassword /compact

or:

msaccess.exe sourcedatabasefile /pwd yourpassword /compact targetdatabasefile

Open in new window

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
hi Hankwembo,

alternately, you can use the DBEngine.CompactDatabase method:
DBEngine.CompactDatabase( SrcName:=sPathFileSource
	, DstName:=sPathFileDestination
	, DstLocale:=";pwd=MyPassword"
	)

Open in new window

This link explains the parameters:
https://msdn.microsoft.com/en-us/library/office/ff844821.aspx

> "We are given a facility to compact the FE on close"

that may not be a good idea ... depending what is being done. It is good to compact/repair just after a file is backed up*, not after development or data entry has been done and the file is not backed up yet because compact/repair can be a volatile process.  Front-ends shouldn't really need to be backed up anyway since they can just be redistributed. So, if this is the case, and you are just housekeeping, then compact on close should be ok for the front-end.

*For this reason, I would suggest compact/repair to a separate file for the back-end.

have an awesome day,
crystal
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.