Results 1 to 2 of 2

Thread: Compact & Repair current Access DB from VBA

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Compact & Repair current Access DB from VBA

    I've put "cleanup" buttons on some of my Access 2000 switchboards that delete temp tables, and I thought it would make sense to do a compact automagically right after that, but ...

    DoCmd.RunCommand acCmdCompactDatabase
    fails with the error message
    "You can't compact the open database while running a macro or Visual Basic code."

    So I tried just simulating the keystrokes:
    SendKeys "%TDC", True

    This works every-other time and fails with the same message on the alternate tries.
    And it closes my switchboard when it does work.

    No big deal, just another one of those little MS annoyances.

    Any ideas? Thanks, DaveBo
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

  2. #2
    Registered User
    Join Date
    Feb 2004
    Posts
    52
    It is best to just compact and repair outside of the app in question. I posted a class to do this here:

    http://www.vbforums.com/showthread.p...hreadid=280667

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width