mloucel
Member
- Local time
- Today, 01:25
- Joined
- Aug 5, 2020
- Messages
- 262
Hello Gurus and Good Morning/Afternoon/Night:
I have a very simple program (my second one), I followed instructions to perform a Compact and Repair Database using VBA and a button
so I tried:
PROBLEM:
Doesn't even run the backup I got a runtime error 70 or permission denied, I have like 30K hairs less, I tried to do it from a main menu, closing the database in case was open, but I have no success.
The CODE is not mine, I do not like to re-invent the wheel, was written by Richard Rost on his YouTube channel., I just modified it a bit to suit my needs.
Yes it works from the Database Tools [Menu] compact and repair option, no problem.
Any Ideas?
I am using Access 64, with Office 365 whatever is the latest.
I have a very simple program (my second one), I followed instructions to perform a Compact and Repair Database using VBA and a button
so I tried:
Code:
Dim Source As String, Dest As String, Result As Boolean
Source="C:\MyData\BE.accdb"
Dest="C:\MyData\Compacted.accdb"
'First Step Backup The Original to avoid any problems
FileCopy Source, Source & ".backup" & Format (Now(), "yyyymmdd")
'Delete dest file if exists
If Dir(Dest) <> "" Then Kill Dest
' Perform Compact
Result=Application.CompactRepair(Source, Dest, False)
If Result Then
' Success
Kill Source
Name Dest As Source
Msgbox "Success"
else
' Fail
Msgbox "Failed"
endif
PROBLEM:
Doesn't even run the backup I got a runtime error 70 or permission denied, I have like 30K hairs less, I tried to do it from a main menu, closing the database in case was open, but I have no success.
The CODE is not mine, I do not like to re-invent the wheel, was written by Richard Rost on his YouTube channel., I just modified it a bit to suit my needs.
Yes it works from the Database Tools [Menu] compact and repair option, no problem.
Any Ideas?
I am using Access 64, with Office 365 whatever is the latest.