Results 1 to 9 of 9
  1. #1
    face is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Location
    South Carolina
    Posts
    7

    Run-time error '76'

    My company assigns network folders to individual employees. I have code that loops thru and builds me a list of the high level folder everyone.

    As VB code ds it's thing I get the Ru-time error '76' on the same 5 or so folders out of thousands. I have debugged and when I do, it works fine. I hit F5 and it fails on the next one on my list of 5. If I do nothing more than go to debug and stop the processing when it hits error 1, then start again, it will get past 1st failure and fail on second one. I debug, stop process, start again, it will not get to #3, and so one and on. Reviewing the data I generated all is good, results are what I expected.



    The failure occurs on this statement after it has successfully written the data from one of the folders I expect to fail on.

    For Each Subfolder In FOLDER.SubFolders

    I originally use mapped drives for this but now use fully qualified network paths as I had learned this could be the problem, didn't help.

    Any clues?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Maybe add a Doevents loop inside your for each next statement to slow it down a bit?
    https://stackoverflow.com/questions/...ders-using-vba
    Cheers,
    Vlad

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    there are those you advise against Do Events to insert a pause, which is why I use a pause function.

    https://www.fmsinc.com/microsoftacce...idDoEvents.asp

    Most pause functions seem to be written for some number of whole seconds but I've found that you can create one for tenths of a second if you use the right data type.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    face is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Location
    South Carolina
    Posts
    7
    I saw the same about Do Events so went with a sleep routine. It did not help.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I debug, stop process, start again,...
    Maybe that doesn't mean what I thought it did. I interpreted that as meaning you step through the code right from the start and got those results, thus maybe things were executing too fast when you ran normally. If not, that's what I'd do, checking variables as I go, knowing that a highlighted line hasn't been processed yet, thus the variables may not be what they will be when I move off of that line. Allowing it to run to failure point and step from there isn't the way to go.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    It would probably really help if we could see the code that is involved here...or see the actual file...with instructions on how to repeat the problem.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You might be interested in thi article comparing different methods of adding a short pause to code execution both in terms of the time added and the impact of each.
    The methods tested were DoEvents, dBEngine.Idle RefreshCache and Sleep
    See http://www.mendipdatasystems.co.uk/s...s-3/4594428909
    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

  8. #8
    face is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Location
    South Carolina
    Posts
    7
    I run my scans and it errors out. I hit the debug option, then stop the process, start it again and it will then throw up another error. However, the 2nd time it has now gotten beyond the point where it first failed. So when I restart the process, I am starting at the beginning. When this first happened, I stopped before the error, stepped thru and never got the error. So, I have 5 or so folders that will give me the error code. Once it hits the error on the first folder, it will never error out on it again until the next day. Once I stop and go thru each of the 5 or so folders, I can start again and it will run clean, until tomorrow.

    For Each Subfolder In FOLDER.SubFolders

    If Len(Subfolder.Path) - Len(Replace(Subfolder.Path, "", vbNullString)) _
    <= lFolderlevel + MAX_LEVEL - 1 Then

    Count = Len(Subfolder.Path) - Len(Replace(Subfolder.Path, "", ""))

    If Count = 10 Then
    Convert = Split(Subfolder.Path, "")

    Drive = Convert(5)
    Server = Convert(6)
    Server2 = Convert(6)
    Company = Convert(7)
    Div = Convert(8)
    CC = Convert(9)
    Employee = Convert(10)
    Path = Subfolder.Path

    If CC <> "Sec" Then

    If Employee <> "Training Documents" Then

    If Employee = "XXXX" Then
    EmpID = "XXXX"
    Else
    Convert = Split(Employee, "(")
    Employee = Convert(0)
    EmpID = Convert(1)

    Convert = Split(EmpID, ")")
    EmpID = Convert(0)

    Ruler = Split(EmpID, "-")
    Counter = UBound(Ruler)

    If Counter > 0 Then
    Convert = Split(EmpID, "-")
    EmpID = Convert(1)
    Else
    End If
    End If
    Else
    End If
    Else
    GoTo MoveOn
    End If

    'If EmpID = "JE14" Then
    ' Whoops = EmpID
    'Else
    ' End If


    iFileNumber = FreeFile
    Open LoadFile For Append As #iFileNumber
    sText = Drive & "," & Server & "," & Server2 & "," & Company & "," & Div & "," & CC & "," & Employee & "," & EmpID & "," & Path
    Print #iFileNumber, sText
    Close #iFileNumber
    GoTo MoveOn

    Else
    End If

    ShowSubFolders2 Subfolder, lFolderlevel, MAX_LEVEL
    End If
    MoveOn:
    'Call sSleep(cTIME)
    Next

  9. #9
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Once it hits the error on the first folder, it will never error out on it again until the next day.
    Sounds like a transient variable value problem IF you're saying this bombs out after n loops. Not clear if you are saying it completely runs once n times, then on another run attempt it will fail OR you are saying you call this once, it loops n times then typically fails at the same point. I'll answer as if it is the latter.

    Next time you run it, start from square 1 by putting a break at the beginning. Since the point of failure seems to be known, either step through to just before that point or allow it to loop until just before that point. If that is after a lot of loops, then I have dealt with this by adding a counter and just holding down F8 to repeatedly loop and periodically checking progress, switching back to slow advance when I get close. The goal is to compare the state of variables, so the watch window will be useful. I don't believe I've tried to construct an IF block where execution branches to when counter reaches a value where that block also has a break point but that may also serve to interrupt at the proper number of loops.

    There are other issues with your code. #1 - please use code tags with indentation (# on menu bar) otherwise large blocks are difficult to read. There are other reasons as well.

    Also, omitting the code parts that tell us that a variable is declared or properly typed doesn't help. It is also not evident that you are using Option Explicit. Code comments explaining the intent would help. For instance, I do not understand your use of the Replace function - looking for a zero length string in a folder path, replacing it with vbNullString, which AFAIK, will be treated the same here. Thus aside from replacing what is essentially a zls with a zls, how could a file path contain a zls in the first place? Maybe there is something there that I could learn?

    Then there is the expectation that I have that if Count <> 10 nothing gets executed between that line and iFileNumber = FreeFile. Does whatever comes after that have all the variables set up correctly? I expect that Drive, Server, etc. are Null in that case.

    You said that the error occurs on For Each Subfolder In FOLDER.SubFolders but didn't show what comes before that.

    If none of that helps, try posting the entire procedure (in code tags) and indicate the status of Option Explicit. However, what seems most problematic for me is what happens if Count does not equal 10. If I missed an End If on that, it proves my point about not being able to accurately read code as general post text.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 13
    Last Post: 05-31-2019, 10:48 PM
  2. Replies: 3
    Last Post: 05-10-2018, 07:48 AM
  3. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  4. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 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