Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 February 24th, 2004, 12:49 PM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default Scheduled Task

I have a scheduled task set up to open an Access DB at 4am, the Access DB has an AutoExec macro and executes several append query's using code. Recently I added code to export records to an Excel file and now I get a nondescript macro error.
When troubleshooting I found the code works fine when I comment out some of the append queries code or the export code, but when I execute all lines I get the error
Could it be a memory issue? I can't think what else it might be?
 
Old February 24th, 2004, 02:05 PM
Authorized User
 
Join Date: Feb 2004
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the procedures can complete sucessfully when run independently, then it should be possible to process them without running into memory problems. In a single threaded environment like Access VBA code runs in, you could conceivably use too many large objects without releasing them before using additional large objects. If it is a memory problem, you can close and set to Nothing any objects that are no longer needed.

Macros do not have error handling/recovery capability. However, in VBA, you can trap and handle or log errors. Your post states that you use VBA but I would suggest that you make sure that there is only a single RunCode line in your macro to call a single Function that calls separate procedures for each query and export. You may reuse the procedure that runs the appends by passing in an SQL string or Query Name and you can reuse the export procedure with appropriate parameters as to source and destination. Splitting the procedure up this way helps ensure that you create and clean up objects sequentially as needed. Make sure you have an error handler in each procedure. Logging the error number and message string to a table will help a great deal if it happens when you are not present.

Instead of relying on a Macro, you may set an opening form in the application startup (Tools menu - Startup...). In the open event, have the form check the system time (Now()) and if it is within 2 minutes of your scheduled time, use it to call your procedures. Assuming you have proper error handlers in place, you have a chance of getting a more useful error message.

Ciao
Jürgen Welz
Edmonton AB Canada
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add task in Scheduled Task programatically amitjoshipune C# 2 July 31st, 2008 05:42 AM
Getting the "Last Result" from a Scheduled Task? janama .NET Framework 2.0 1 April 29th, 2008 12:37 AM
Scheduled task langer123 Classic ASP Basics 0 March 16th, 2005 11:14 AM
In program Scheduled Task ginoitalo Pro VB 6 4 August 31st, 2004 11:32 PM
[c#]scheduled task maddonuts General .NET 1 July 7th, 2004 11:53 AM





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