Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Autoexec issue in Access 2003

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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.
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.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

618 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