[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

How do I compact and repair a database with a password

I'm trying to compact and repair a password protected database with the following code:

Public Sub Compact()
   Dim CurrentFile As String, BackupFile As String
   On Error GoTo 0
   CurrentFile = "C:\CAV3\Database1.accdb"
   BackupFile = "F:\Database1.accdb"
   If Dir(BackupFile) > "" Then
      Kill BackupFile
   End If
   Application.CompactRepair CurrentFile, BackupFile, True
   Exit Sub
   
End Sub

How do I change it to supply the password?

Thanks in advance.
0
CRB1609
Asked:
CRB1609
1 Solution
 
Rey Obrero (Capricorn1)Commented:
look at DBEngine.CompactDatabase Method

http://msdn.microsoft.com/en-us/library/office/ff844821(v=office.15).aspx

DBEngine.CompactDatabase CurrentFile, BackupFile, ";pwd=password", , ";pwd=password"
0
 
CRB1609Author Commented:
Perfect.  Thank you.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now