Repair, Compact, and Back Up Access MDB

Repair, Compact, and Back Up Access MDB

This repair and compact also backs up the Access MDB.

 Function ValidateMdb(MDB As String) As Boolean

This function repairs, compacts, and backs up a database fileand deletes stray LDB (locking files) as it goes. The concept is to copy the file to a BAK version, then repairand compact the BAK back to the original. The renaming keeps it frombeing opened before you get a change to compact it, and it provides a backup since the client doesn’t do that. I call it Validate because NOBODY wants to wait for a file to bebacked up or compressed but everybody wants their data validated!

 'Sample'Dim bSuccess As Boolean'bSuccess = ValidateMdb("c:my documentsdb2.mdb")     Pat Tormey [email protected] dbe As New DBEngine  'Set Ref to MS DAODim sLdb As String 'Locking file's NameDim sBak As String 'BackUp file's NameDim rv As Boolean  'My standard for a return variableOn Error GoTo ProcErr    rv = False    If Len(Dir(MDB)) = 0 Then 'No File Found     GoTo ProcExit    End If    sLdb = Left$(MDB, InStr(MDB, ".")) & "LDB"    sBak = Left$(MDB, InStr(MDB, ".")) & "BAK"    Kill sLdb  'delete it if you can   If Dir$(sLdb) <> "" Then 'is it still here? Still in Use     GoTo ProcExit   End If 'Locked   If Dir$(MDB) <> "" Then 'this is to be sure I don't delete the BAK     Kill sBak                        if the MDB isn't around     Name MDB As sBak 'Prevents somebody else from opening it   End If 'Is there an MDB      dbe.RepairDatabase sBak 'repair the backup      dbe.CompactDatabase sBak, MDB 'compact back to original      rv = TrueProcExit: ValidateMdb = rv Exit FunctionProcErr:  If Err = 53 Then 'Probably LDB not found   Resume Next  End If 'Err   rv = False  Resume ProcExitEnd Function
Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as