Solved

Autoexec issue in Access 2003

Posted on 2008-09-30
2
340 Views
Last Modified: 2013-11-27
I need to run an autoexec macro once when access is opened the first time each month and only run the first time it is opened. The file may be opened 5 times in one day or every 5 days.  Due to other considerations the control must be within Access itself.  Please advise.  Thanks.
0
Comment
Question by:Jim_W_in_AZ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
ldunscombe earned 500 total points
ID: 22611830
You could do this,

Create a table lets call it tbl_RunCheck with two fields.  ID (Numeric) and LastRun (Date).  You will only need one record.

Create 1 record with an ID value of 1. and any date in the previous month to when you want it to run next.
Then in the OnOpen event of your start up form.

'If the last run date in the Run Check table is the current month then don't run the macro.
if month(dlookup("LastRun","tbl_RunCheck","ID = 1")) = month(now()) then
exit sub

else 'If the last run date in the RunCheck table is not the current month then run the macro and reset the new date in the table
Docmd.runmacro "The Name Of Your Macro"
'The following three lines will set the date in the run check table to the current date
dim strsql as string
strsql = "UPDATE tbl_RunCheck SET tbl_RunCheck.LastRun = Now();"
docmd.runsql strsql
end if

Leigh

0
 

Author Closing Comment

by:Jim_W_in_AZ
ID: 31501802
Thank you so much.  I knew the process but had no clue how to code it.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question