Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 24th, 2004, 12:49 PM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
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?
Reply With Quote
  #2 (permalink)  
Old February 24th, 2004, 02:05 PM
Authorized User
 
Join Date: Feb 2004
Location: Edmonton, Alberta, Canada.
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
jwelz@hotmail.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:19 AM.


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