Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2002
    Location
    London
    Posts
    73

    Unanswered: Compact ms Access db using vba code

    Hi,

    Does anyone know how to compact a ms access 2000 db in vba code. I want the database to compact evertime it is opened up.

    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    There are several ways to do this. One is the undocumented SysCmd:

    Code:
      
    	Dim oAcc As Access.Application
    	
    	Set oAcc = New Access.Application
    	
    	oAcc.SysCmd 602, "C:\MyDB.mdb", "C:\MyDB.mdb"
    Just reread - this actually compacts a remote db - not sure if you can use it to compact itself. You could just select Compact On Close in Tools--> Options of course.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    239
    Be aware, this counts only for Access 97.
    In 2002 it delete the MDB. :-/

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    DELETED - Pootle already pointed out compact on close
    currently using SS 2008R2

Posting Permissions

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