Solved

Autoexec issue in Access 2003

Posted on 2008-09-30
2
303 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now