Solved

Autoexec issue in Access 2003

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HasData 9 37
Reset Active Directory Password via MS Access 9 55
Two list boxes - best structure 3 32
field number type in access tabledefs fields 5 19
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

895 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

15 Experts available now in Live!

Get 1:1 Help Now