How do i get a Module to run on the last day of each month.

  • Thread starter Thread starter Brendanpeek
  • Start date Start date
B

Brendanpeek

Hello all

I need to find a way to run a module on the last day of every month, But
without using the "On Timer" event. Since it is all ready being used. The
Module is called KPICalStep1.

Thank you for your time.
 
1) Does the database get opened every day of the month?
2) Do you want the code to only run once on the last day or does it have to
run multiple times?

I will assume
++ that the database is not running continuously
++ you only want to run KPICalStep1 once per period
++ that the database may not always be opened on the last day of the month
when the last day of the month falls on a weekend or Holiday.

I would create a table with a field to record the next execution day.

When the database opens (assuming you have some form that always opens) use
the form's On load event to check to see if the current date is greater than
the next execution date.

If so, run your code and as part of the code set the next execution date to
the next end of the month.


Something like this would set the date for the end of the following month.

ExecutionDate = DateSerial(Year(ExecutionDate),Month(ExecutionDate)+1,0)



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
OK got ya about the modules. i already have a swictboard which is always open
and the event timer is used as well as the form open event, plus the Db never
gets closed or opened, once i have finished designing the Db and open it, it
will never be closed.
 
Please Refer to my second post.

John Spencer said:
1) Does the database get opened every day of the month?
2) Do you want the code to only run once on the last day or does it have to
run multiple times?

I will assume
++ that the database is not running continuously
++ you only want to run KPICalStep1 once per period
++ that the database may not always be opened on the last day of the month
when the last day of the month falls on a weekend or Holiday.

I would create a table with a field to record the next execution day.

When the database opens (assuming you have some form that always opens) use
the form's On load event to check to see if the current date is greater than
the next execution date.

If so, run your code and as part of the code set the next execution date to
the next end of the month.


Something like this would set the date for the end of the following month.

ExecutionDate = DateSerial(Year(ExecutionDate),Month(ExecutionDate)+1,0)



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Brendanpeek said:
ok cheers guess i need to rethink the whole thing.

Make another MDB file (perhaps from a copy of your current one) and set it
up so that all it does when you open it is run your functions and then
closes itself. Set up your windows scheduler to open that file on the last
day of each month. Use your current file for everything else you need to
do.
 
Back
Top