Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    17

    Waiting for shell to finish

    This is with Access 97. I am trying to use Jetcomp to compact a separate database from the one executing the code.

    Somehow the flow of my code is continuing when it should not. Consequently, a file is still locked when the next command tries to delete it. I get a Permission Denied error and the code breaks with the debugger at the offending line. After a few seconds, I click the continue button. Same thing happens. I wait a few more seconds. I click the continue button and it proceeds as it should.

    As you can see below, I can get it to work using "Sleep", but that is inelegant and requires me to guess how long it's going to take to be ready.



    So how do I prevent the second command from executing until the first command is truly done and all the file locks or whatever are freed up?

    Here is the code:

    Code:
    Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
    
    
    Function test()
    
    
        Name "J:\newco.mdb" As "j:\newco_temp.mdb"
    
    
        SysCmd acSysCmdSetStatus, "Compacting newco..."
    
    
    1    Shell "J:\jetcomp.exe -src:" & "j:\newco_temp.mdb" & " -dest:""J:\newco.mdb"" -v3"
        
        If Dir("J:\newco.mdb") = "" Then
            SysCmd acSysCmdSetStatus, "Jetcomp failed"
            Name "j:\newco_temp.mdb" As "J:\newco.mdb"
        Else
            SysCmd acSysCmdSetStatus, "Sleeping..."
            Sleep 2000
    2     Kill "J:\newco_temp.mdb"
        End If
        
        SysCmd acSysCmdSetStatus, "Success."
    
    
    End Function

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

  3. #3
    Join Date
    Jul 2011
    Posts
    17
    Quote Originally Posted by RuralGuy View Post
    That worked. Thanks!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Glad we could help.

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

Similar Threads

  1. Waiting for a web form to reload
    By Jrbeene86 in forum Access
    Replies: 1
    Last Post: 11-02-2012, 11:04 AM
  2. How to finish it
    By Abarency in forum Access
    Replies: 1
    Last Post: 09-12-2012, 06:08 PM
  3. Waiting for Insert/Update to finish
    By EddieN1 in forum Access
    Replies: 6
    Last Post: 12-12-2011, 12:15 PM
  4. Waiting Time
    By John Southern in forum Reports
    Replies: 4
    Last Post: 05-25-2010, 09:46 AM
  5. Need some support to finish DB
    By Estyl in forum Access
    Replies: 0
    Last Post: 04-22-2008, 04:34 AM

Tags for this Thread

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