Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2007

Tip: Looking for answers? Try searching our database.

Code for first of the month

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul.S - 18 Nov 2006 22:50 GMT
I want create code that will call a function on the first day of each month.
Any help?
freakazeud - 19 Nov 2006 00:46 GMT
Hi,
you could try:

If DateSerial(Year(Date),Month(Date),1) = Date Then
'execute your code
End If

HTH
Good luck
Signature

Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)
http://www.oli-s.de

> I want create code that will call a function on the first day of each month.
> Any help?
Dirk Goldgar - 19 Nov 2006 01:19 GMT
> Hi,
> you could try:
>
> If DateSerial(Year(Date),Month(Date),1) = Date Then
> 'execute your code
> End If

Wouldn't

   If Day(Date) = 1 Then
       ' ...

be simpler?

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Paul.S - 19 Nov 2006 17:31 GMT
Thanks everyone...

> > Hi,
> > you could try:
[quoted text clipped - 9 lines]
>
> be simpler?
Peter R. Fletcher - 19 Nov 2006 10:09 GMT
>I want create code that will call a function on the first day of each month.
>Any help?

Dirk's solution is simplest as long as you can guarantee that the
_calling_ code will run (at least once) on the first day (which may
not be a working day) of every month. If what you really want is to
ensure that your function is called on the first occasion on which the
application and/or calling code runs in each new month, which is
rather different (and somewhat more probable in most business
applications), you will have to be more creative. In this case, you
will need to save the current month value, either in a Table, or in
the Registry, each time the program runs, and compare the new current
month with the saved value on startup to determine if you are in a new
month.

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
bml337 - 07 Nov 2007 21:05 GMT
what if the database is never shutdown? will the code still execute?

my dilemma...

I need to create a supervisory log for my clients.  The log table has the
following fields date, checkbox and notes.  now for the tricky part... one
log is weekly and should be generated every monday.  i have a similar log
that will be run on the first of each month.

so i need a record auto generated every Monday of the week and another
generated on the first of every month... these will be in two separate tables.

.. also possible to auto email to the client???

from there i will email that record w/access 2007 to the client so they can
fill out the rest of the information.  then i can append the record back the
DB and create a report.

suggestions please and thanks in advance.

>>I want create code that will call a function on the first day of each month.
>>Any help?
[quoted text clipped - 13 lines]
>Please respond to the Newsgroup, so that others may benefit from the exchange.
>Peter R. Fletcher

Signature

brandon

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.