Results 1 to 11 of 11
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Error on Compacting

    This database needs to be compacted each time it is closed. This has NEVER been an issue with any database I have ever worked on, till now. I sporadically get this error "Access is unable to rename database.accdb" and then access closes. Of course database.accdb is my compressed database, but this would be catastrophic if this happened in the field. It doesn't happen every time. This is something that just popped up in the last day or two. I'm not sure what to think.



    Thanks in advance,

    Paul

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    try creating a new blank db,
    import EVERYTHING from the old one. (including relations, etc)
    then try compacting that.

    you shouldnt have to compact everyday.

  3. #3
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,042
    it sounds like the database is still in use by another user. Close the database and check if there still exists a laccdb file. If so, and nobody else but you is working with the database, delete the laccdb file and try again.

  4. #4
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by NoellaG View Post
    it sounds like the database is still in use by another user.
    It a singe user database mean to be used by one person at a time. There is no back end. I am working on a local copy on my desktop.

  5. #5
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Quote Originally Posted by ranman256 View Post
    try creating a new blank db,
    import EVERYTHING from the old one. (including relations, etc)
    then try compacting that.

    you shouldnt have to compact everyday.
    Yeah, I'll probably try that.

    There is no back end. Users get their own copy and import new batches of data. That data is purged each time there is a new import. Over time the db can get quite bloated. The compact on close is meant to take care of that.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Using compact automatically on close can easily lead to corruption if the process gets interrupted.
    Far better to make a backup then do a compact when it is actually needed.
    Better still, modify the approach so temporary data is stored in a separate 'side end' database which can be deleted and replaced as necessary.

    In the meantime, before importing everything into a new blank database, try decompiling to remove any corrupt code. It only takes a second or two.
    See http://www.mendipdatasystems.co.uk/c...lds/4594523656
    Before you do so, make a backup. Afterwards recompile then compact.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I think I've found a solution This database needs to be compact occasionally, ideally monthly. I have found a way to Compact on demand using VBA.

    I've added a button to set the Compact on Close property to True.

    Code:
    Private Sub cmdCompact_Click()
    If MsgBox("Compact and Repair should be performed once per month." & vbNewLine & vbNewLine & _ "Click yes to Compact on exit.", vbYesNo, "Compact and Repair") = vbYes Then Application.SetOption "Auto compact", True MsgBox "Data Quality tools will compact on closing" End If
    End Sub
    and then set it back to being False when the application opens.

    I understand the corruption issue, but since all data is stored elsewhere and only imported when needed there is no chance of corruption of data.
    If needed the user can just download a fresh copy of the application.

    By compacting only on demand I hope to avoid this.

    My next step, if I have time, will be to store the date of the last Compact and Repair and have it run monthly after that.

    Your thoughts?

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Why not just compact based on file size? If the characteristic of a db is that it needs compacting more frequently than some, then surely this is driven by use. Usage could be 3x in one month what it was in the prior month, so does a time period make as much sense as a file size? Not to me. Question is, what is the file size you'd pick? Experience would probably tell you that.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    These databases sit on the users desktop. There is no back end I can compact. Each user will have different size files which they can import multiple times. The tables are all cleared each time they import. Depending on their use they can balloon in size. I don't think I can depend on them to check on the file size, so I put in a recommendation that they compact once each month. Is there a way I can trigger this based on file size?

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    I don't think I can depend on them to check on the file size, so I put in a recommendation that they compact once each month. Is there a way I can trigger this based on file size?
    have some vba code which runs when the user closes the db

    if filelen(currentdb.Name)>???? then
    'compact
    end if

  11. #11
    Paul H's Avatar
    Paul H is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    That worked, thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compacting or referencing code
    By Thompyt in forum Programming
    Replies: 4
    Last Post: 12-16-2016, 06:10 PM
  2. Compacting Error on .mdb Back End
    By Paul H in forum Access
    Replies: 2
    Last Post: 02-24-2016, 11:33 AM
  3. db compacting
    By aiken_Bob in forum Access
    Replies: 5
    Last Post: 06-25-2010, 01:22 AM
  4. Compacting When Closing?
    By Sean04 in forum Access
    Replies: 5
    Last Post: 03-19-2010, 01:16 PM
  5. Compacting MS Access
    By ksenthilbabu in forum Access
    Replies: 4
    Last Post: 08-20-2009, 04:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums