?
Solved

Autoexec issue in Access 2003

Posted on 2008-09-30
2
Medium Priority
?
346 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

741 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