By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Error Handling Issue

P: 2
Has anyone see an issue in an Access 2010 VBA procedure where the second time an error occurs it will return to the calling procedure?

I have error handling enabled in a procedure and it works fine the first time around, but then the second time an error occurs it will exit the procedure and return to the calling proc.

I have a routine that loops through some folders and files and tries to move the files. if any of them are in use, then it should skip the file and move the next one.

Thanks in advance
Dec 19 '11 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,315
It would help to see the code.
Dec 19 '11 #2

P: 2
Thanks for looking Rabbit... below is the scaled down code. there are some database calls and stuff in the middle but the error handling routines are intact..

Expand|Select|Wrap|Line Numbers
  1. Public Sub GetNetworkFiles()
  2. Dim fs                  As New FileSystemObject
  3. Dim fld                 As Folder
  4.  
  5. On Error GoTo GetNetworkFiles_Error
  6.  
  7.     Set fld = fs.GetFolder(IncomingFolder)
  8.  
  9.     For Each objFile In fld.Files
  10.         'move the file
  11.         fs.MoveFile IncomingFolder & "\" & FileName, OutgoingFolder & "\" & FileName
  12.     Next
  13.  
  14. Exit Sub
  15.  
  16. GetNetworkFiles_Error:
  17.  
  18.     If Err.Number = 70 Then Resume Next'permission denied to the file - most likely file is open
  19.  
  20.     If Err.Number = 53 Then Resume Next 'file not found error - user may have renamed or deleted
  21.  
  22.     If Err.Number = 76 Then 'path not found - folder is missing
  23.         LogAppError Err.Number, Err.Description & "-" & IncomingFolder, "GetNetworkFiles", "mod_Process", Erl
  24.         Resume Next
  25.     End If
  26.  
  27.     LogAppError Err.Number, Err.Description, "GetNetworkFiles", "mod_Process", Erl
  28.  
  29. End Sub
  30.  
Dec 19 '11 #3

NeoPa
Expert Mod 15k+
P: 31,186
That typically happens when an error handling routine fails to compete its handling for some reason (EG. returns to main code without a Resume). I see nothing in the posted code that might cause that.
Dec 20 '11 #4

100+
P: 759
Or if you have an error inside the error handling routine.
What is and how work LogAppError ? Is no need to a Resume statement after that ?
Dec 20 '11 #5

NeoPa
Expert Mod 15k+
P: 31,186
Mihail:
Or if you have an error inside the error handling routine.
That is just one of the situations "when an error handling routine fails to complete its handling". It is not an alternative.

Mihail:
What is and how work LogAppError ? Is no need to a Resume statement after that ?
That could refer to line #23 or #27. I assume you intended to refer to line #27.

LogAppErr, I would assume, is a procedure defined elsewhere. Line #27 wouldn't require a Resume if the intention is for the procedure (GetNetworkFiles()) to exit. Such a situation (as the code stands) would not allow any further processing within that procedure anyway, so cannot be what the OP is asking about.
Dec 21 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.