Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Unanswered: compact & Repair, What am i doing wrong

    Dim str As String
    str = CurrentDb.Name
    currentdb.Close
    DoCmd.Close
    Application.CompactRepair str, str & ".tmp", False


    this is the code i'm using but it says can't compact the current db what have i missed?
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  2. #2
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100
    Is it something to do with exclusive opening?

    I think I remember prevous versions of access only letting you compact and repair if you have opened the db exclusively.

  3. #3
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by xander
    Is it something to do with exclusive opening?

    I think I remember prevous versions of access only letting you compact and repair if you have opened the db exclusively.
    i can manually C&R but i want to automat the process and it won't do it
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  4. #4
    Join Date
    Apr 2002
    Posts
    139
    You may have a look at
    http://dbforums.com/showthread.php?threadid=585322

    However, still not found the solution.

    Marion

  5. #5
    Join Date
    Aug 2002
    Location
    Northampton, England
    Posts
    266
    In Access 97 and 2000, the menu option to Compact the current database CANNOT be duplicated from code. Jet requires the database to be closed before any compact procedures are run. So as long as you have any code running, the Current database is not closed, hence the compact routines cannot run.

  6. #6
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by DJN
    In Access 97 and 2000, the menu option to Compact the current database CANNOT be duplicated from code. Jet requires the database to be closed before any compact procedures are run. So as long as you have any code running, the Current database is not closed, hence the compact routines cannot run.
    that the conclusion i'd come up with now can you suggest a solution?
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  7. #7
    Join Date
    Nov 2002
    Posts
    7
    Have the code open another Access database and close the current one. In the other database, run the code to compact and repair on the closed database, then open the original one, and close the second db.

  8. #8
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by 10 Pence Short
    Have the code open another Access database and close the current one. In the other database, run the code to compact and repair on the closed database, then open the original one, and close the second db.
    so i have to have a second database just to compact a database?
    how about i stick the code in a stand alone VB program will the vb program run before the DB shuts down?
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  9. #9
    Join Date
    Mar 2003
    Location
    Romania
    Posts
    32
    You can use /compact or /repair (Startup command-line of MS Access).
    Florin Profeanu
    floreanuprofin@yahoo.com

  10. #10
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by florin.profeanu
    You can use /compact or /repair (Startup command-line of MS Access).
    that requires a seperate short cut to be run by the user i want the thing to be automatic with out the user doing anything
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

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