473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Error Handling Issue

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
5 1896
Rabbit
12,516 Expert Mod 8TB
It would help to see the code.
Dec 19 '11 #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
32,556 Expert Mod 16PB
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
Mihail
759 512MB
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
32,556 Expert Mod 16PB
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

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

Similar topics

1
by: Jon LaRosa | last post by:
Hi all - I have a web application and I want to be able to do some basic error handling. For example, here is one error I would like to catch and display in a useful way for the user: ...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
14
by: Al Smith | last post by:
I need help in implementing proper error handling. I am trying to upload a file based on the sample code below. The code works well except if the file selected is too big. I do know about the...
9
by: Gustaf | last post by:
I'm confused about structured error handling. The following piece of code is a simplification of a class library I'm working on. It works, and it does what I want, but I'm still not convinced that...
33
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
3
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
2
by: Carol | last post by:
Exception may be thrown in the code inside the try block. I want to handling the SqlException with State == 1 in a special way, and for all others I want to use a general way to handle. Which of...
5
by: kellygreer1 | last post by:
I think I'm not quite understanding something about error handling in PHP5. I have written some PHP code to index the contents of C drive on a Windows machine. When it gets to certain special...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.