Avatar of Clive Beaton
Clive Beaton
Flag for Australia asked on

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.
Microsoft Access

Avatar of undefined
Last Comment
Clive Beaton

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rey Obrero (Capricorn1)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Clive Beaton

ASKER
Perfect.  Thank you.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck