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
5 1909 Rabbit 12,516
Recognized Expert Moderator MVP
It would help to see the code.
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.. - Public Sub GetNetworkFiles()
-
Dim fs As New FileSystemObject
-
Dim fld As Folder
-
-
On Error GoTo GetNetworkFiles_Error
-
-
Set fld = fs.GetFolder(IncomingFolder)
-
-
For Each objFile In fld.Files
-
'move the file
-
fs.MoveFile IncomingFolder & "\" & FileName, OutgoingFolder & "\" & FileName
-
Next
-
-
Exit Sub
-
-
GetNetworkFiles_Error:
-
-
If Err.Number = 70 Then Resume Next'permission denied to the file - most likely file is open
-
-
If Err.Number = 53 Then Resume Next 'file not found error - user may have renamed or deleted
-
-
If Err.Number = 76 Then 'path not found - folder is missing
-
LogAppError Err.Number, Err.Description & "-" & IncomingFolder, "GetNetworkFiles", "mod_Process", Erl
-
Resume Next
-
End If
-
-
LogAppError Err.Number, Err.Description, "GetNetworkFiles", "mod_Process", Erl
-
-
End Sub
-
NeoPa 32,569
Recognized Expert Moderator MVP
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.
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 ?
NeoPa 32,569
Recognized Expert Moderator MVP 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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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:
-----------------
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
UPDATE statement
|
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 if "global variables get re-set" doesn't tell the whole story, then what
does?
***please note***
I'm not looking for a solution - I'm looking for a more detailed description
of what happens when an un-handled error occurs - possibly with help file...
|
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 maxRequestLength parameter of the <httpRuntime> section
and that works as expected. What I want is to enforce a max file size but
haven't been able to trap the error thrown when the file is too large and
that's where I could use some help.
|
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 I have been
doing it right. I think I overdo it. Please have a look:
--
using System;
using System.IO;
|
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 that ID, otherwise it returns
false.
**I am not looking for comments on the usefulness of this function - it is
only to demonstrate error handling**
There are three versions of this code. David Fenton says under the earlier
thread "DAO...
| |
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 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 that ID, otherwise it returns
false.
**I am not looking for comments on the usefulness of this function - it is
|
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 httpRuntime.maxRequestLength
For point 1. it would be good to at least display a nice error page. IE
seems to just display a blank page.
|
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 gets about
3 or so. It also gets very awkward in nested loops, where you want to
check for normal loop processing in the loop condition, not errors.
Yes, you could put some generic exit flag in the loop condition, but
when you're simply done if...
|
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 the
following options is better?
-----------------------------------------------------
Option 1:
try{...}
catch (System.Data.SqlClient.SqlException ex)
{
if (ex.State == 1)
|
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 folders (fake
folders) it runs into errors. Directories it can not read from. I
have tried wrapping the code in a Try / Catch and the error still
comes through. What am I missing?
<?php
// Here is the code:
function indexFiles($path, $handle) {
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |