Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 895001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:29:16+00:00 2026-05-15T14:29:16+00:00

I’m trying to make a small VBScript that compacts a MS Access 2007 database

  • 0

I’m trying to make a small VBScript that compacts a MS Access 2007 database file.

The code I have is:

Set acc2007 = CreateObject("DAO.DBEngine.36")
acc2007.CompactDatabase "C:\test.accdb", "C:\test2.accdb", Nothing, Nothing, ";pwd=test"
Set acc2007 = Nothing

I’m getting this error when I run the three lines with “cscript test.vbs” from a 32-bit cmd.exe:

C:\test.vbs(10, 1) DAO.DbEngine: Unrecognized database format ‘C:\test.accdb’.

The database was created with MS Access 2007, when I open it by double-clicking the icon I type the password “test” and then i opens normally. It says “Access 2007” at the top so it has the correct format.

Here’s documentation of the function I’m trying to use: http://msdn.microsoft.com/en-us/library/bb220986.aspx

The object DAO.DBEngine.36 is created successfully since I’m not getting any errors on that line. What can be wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:29:17+00:00Added an answer on May 15, 2026 at 2:29 pm

    DAO 3.6 does not support the new ACCDB database format. Try DAO.DBEngine.120 instead.

    Here is an example which works on my system.

    Dim objFSO
    Dim objEngine
    Dim strLckFile
    Dim strSrcName
    Dim strDstName
    Dim strPassword
    
    strLckFile =  "C:\Access\webforums\foo.laccdb"
    strSrcName =  "C:\Access\webforums\foo.accdb"
    strDstName =  "C:\Access\webforums\compacted.accdb"
    strBackup = "C:\Access\webforums\foobackup.accdb"
    strPassword = "foo"
    
    Set objEngine = CreateObject("DAO.DBEngine.120")
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If Not (objFSO.FileExists(strLckFile)) Then
        If (objFSO.FileExists(strBackup)) Then
            objFSO.DeleteFile strBackup
        End If
        If (objFSO.FileExists(strDstName)) Then
            objFSO.DeleteFile strDstName
        End If
        objFSO.CopyFile strSrcName, strBackup
    
        ''dbVersion120 = 128 
        objEngine.CompactDatabase strSrcName, strDstName, , 128, ";pwd=" & strPassword
    
        objFSO.DeleteFile strSrcName
        objFSO.MoveFile strDstName, strSrcName
    End If 'LckFile
    

    Note: I decided to make a backup of my database before compact. At the end, I remove the original (uncompacted) database and rename the compacted one to the original name. If you’re not interested in that, you could simplify this by removing the objFSO stuff.

    Edit: Revised to check for lock file; if found do nothing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a reasonable size flat file database of text documents mostly saved in
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.