Results 1 to 4 of 4
  1. #1
    sngsc6 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2021
    Posts
    2

    'Permission denied' not catched in ErrorTrap

    Hello,

    I try to move a file which was created by an external batch-file. However sometimes the newly created file is not 1005 there yet, on the moment Access tries to move this file.
    This might have to do with other processes on that computer (Outlook is checking Emails, internet pages are refreshed, etc).

    To prevent unnecessary waiting-time, I did try to catch that 'Permission denied, Run-time error 70'-error into the 'On Error GoTo' function.
    However, I do not succeed. The error is still shown on screen although the Error-trap should take another second 'Pause-time' before retrying the MoveFile command.

    The script is as follows:


    Private Sub StartProc_Click()



    ............


    If Not rs.BOF And Not rs.EOF Then rs.MoveFirst
    While (Not rs.EOF)


    ............


    Call Shell(BatchFile, vbHide)


    BatchFile:
    On Error GoTo ErrTrap

    TNow = Time
    TWait = DateAdd("s", 1, TNow)
    Do Until TNow >= TWait Or TNow - TWait < -0.05
    TNow = Time
    Loop

    ............


    CopyFrom = [Forms]![DB - 05 - Create KAP bestanden]![ConversionMap] & "" & rs1.Fields("Map-name") & ".KAP"
    CopyTo = [Forms]![DB - 05 - Create KAP bestanden]![KAPStore] & ""

    On Error GoTo ErrTrap
    fso.MoveFile CopyFrom, CopyTo



    GoTo NextItem:

    ErrTrap:


    Resume BatchFile

    End Sub



    Can somebody explain, why the error-trap is letting me down?

    Thanks on forehand

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    Have you debug.print your file paths to see if they are valid and that you have permissons to access them.

    Have you tried DoEvents or a Sleep/ wait procedure? https://www.fmsinc.com/microsoftacce...idDoEvents.asp
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    sngsc6 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2021
    Posts
    2
    Hello moke123,

    Quote Originally Posted by moke123 View Post
    Have you debug.print your file paths to see if they are valid and that you have permissons to access them.

    Have you tried DoEvents or a Sleep/ wait procedure? https://www.fmsinc.com/microsoftacce...idDoEvents.asp
    No, I did not Debug.Print the file-path, but lots of times it goes fine. Only when the HD of the computer is also doing something else, it takes longer for the batch-file to finnish.
    When the error comes up, and I press 'Debug', followed by F5 (Continue script), it goes fine as well.

    The reason for doing this via the errortrap, is that lots of times the system is only requiring one second for the batch-file to finnish. But just in case the HD is busy, it is requesting some extra time.
    Building that time into the script by default, it makes the whole procedure unrequired and unnecessary long. The total procedure can have loops of more that 1000 times, so every second counts.

    So I am looking for the reason, why the 'Permission denied'-error is not trapped in the error-trap procedure.

    Regards,

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Post 3 was moderated, I'm posting to trigger email notifications.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 08-12-2019, 05:58 AM
  2. Permission Denied Run Time Error 70
    By nick243 in forum Security
    Replies: 0
    Last Post: 03-14-2019, 12:13 PM
  3. Replies: 3
    Last Post: 01-21-2017, 04:09 AM
  4. Getting Permission Denied error when moving file
    By ricksil in forum Programming
    Replies: 2
    Last Post: 01-20-2016, 11:21 AM
  5. Replies: 3
    Last Post: 09-01-2010, 08:43 PM

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