PC Review


Reply
Thread Tools Rate Thread

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

 
 
Brendanpeek
Guest
Posts: n/a
 
      12th Sep 2008
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.
 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      12th Sep 2008
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 wrote:
> 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.

 
Reply With Quote
 
Brendanpeek
Guest
Posts: n/a
 
      12th Sep 2008
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.

"Chris O'C via AccessMonster.com" wrote:

> Once you have a list of procedures you want to run only on the last day of
> the month, create a form, set it as your startup form, and in the form_open
> event put this code:
>
> if (Date() = DateSerial(Year(Date()),(Month(Date())+1),0)) then
> call function1
> call function2
> 'etc
> end if
>
> docmd.openform "switchboard"
> docmd.Close acForm, me.name
>
>
> Every time the db is opened it opens the form, checks if today is the last
> day of the month and if it is, runs the functions, then opens the switchboard
> and closes the startup form. If it isn't the last day of the month it opens
> the switchboard and closes the startup form.
>
> Chris
> Microsoft MVP
>
>
> Chris O'C wrote:
> >You can't run a module, it's a container object. You can run the procedures
> >contained in the modules but you have to know the names of those procedures.
> >
> >Chris
> >Microsoft MVP
> >
> >>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.

>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...dules/200809/1
>
>

 
Reply With Quote
 
Brendanpeek
Guest
Posts: n/a
 
      12th Sep 2008
Please Refer to my second post.

"John Spencer" wrote:

> 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 wrote:
> > 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.

>

 
Reply With Quote
 
Brendanpeek
Guest
Posts: n/a
 
      12th Sep 2008
ok cheers guess i need to rethink the whole thing.

"Chris O'C via AccessMonster.com" wrote:

> Access is the wrong tool to use for an app that must run 24/7. You shouldn't
> back it up unless it's closed. To compact it, you close the db and reopen
> the new file. In your scenario there'd be no good backups, no
> compact/repairs. Disaster awaits you.
>
> Chris
> Microsoft MVP
>
>
> Brendanpeek wrote:
> >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.

>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...dules/200809/1
>
>

 
Reply With Quote
 
Rick Brandt
Guest
Posts: n/a
 
      12th Sep 2008
Brendanpeek wrote:
> 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.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avg. 1-month, 3-month, 6-month & 12-month Stock Returns ryguy7272 Microsoft Access Queries 2 7th Feb 2010 03:28 PM
VBA code in one Module referencing Public Variables Declared inanother Module failing Khurram Microsoft Excel Programming 5 11th Mar 2009 11:01 PM
Print Current Month with last month and next month in Header JMoore0203 Microsoft Outlook Calendar 1 5th Dec 2007 04:15 PM
printing Little Current month and Little Next month on Banner when it should little PRIOR month and little Next month. jake_allen10@hotmail.com Microsoft Outlook 0 3rd Nov 2006 07:30 PM
month name module Catherine Cook Microsoft Access VBA Modules 2 6th Dec 2003 04:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 PM.