Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 26th, 2005, 07:02 AM
Authorized User
Join Date: Mar 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error handle - stop exec. of parent function

I have a Function Func1 which calls a procedure Proc1. Func1 find all ".txt" file names from a folder and import them onebyone. When an error occurs in Proc1 (for ex. a wrong format of one of the txt files) i want to stop the execution of code from func1 and not only the code from proc1. Thanks.

Old September 26th, 2005, 05:34 PM
Friend of Wrox
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts

Without seeing you code, it will be difficult to be very specific.

I would change the Proc1 to a funtion so that you can pass back it it was successful. Then in the Func1 yo ucan aadd error handling.

"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.
Old September 27th, 2005, 01:55 AM
Authorized User
Join Date: Mar 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts

Ok, Boyd , but how should look the error handling code from Func1 to stop execution if an error ocured in Proc1(which is a function now, let's say Func2)?
Whith the code below, every time I get an error in Func2 (let's say that one of the .txt files doesn't exist) the application continue to run and import the rest of the files.

On Error GoTo ErrHandle
Do While
---some code to select a file from a folder
Call Func2()

Exit Function
    MsgBox Err.Description
        Set ExcelWorkbook = Nothing
        Set ExcelApp = Nothing
    Exit Function

End function

Func 2()

---code to import .txt file.

End Function

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a image file using exec function foka PHP How-To 1 May 29th, 2005 04:46 PM
EXEC function ajutla Beginning PHP 0 August 19th, 2004 09:18 AM
How to handle this error Maxood Classic ASP Databases 2 June 27th, 2004 02:57 PM
EXEC function not returning values aingalsbe PHP How-To 0 June 1st, 2004 10:03 AM
Getting Error 'EXEC' : undeclared identifier JAPPY Visual C++ 0 April 7th, 2004 09:35 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.