Conditional Macro

  • Thread starter Thread starter Maria
  • Start date Start date
M

Maria

Hi,

I have created an autoexec macro that runs every time the database is
opened. However, I only want the macro to run just once daily. I know that
there is a way to do this by running code attached to autoexec that checks
if the macro has been run and updates a field in a table with the date that
the macro ran and checks it against todays date and does not run again until
the following day. I don't know how to write code, and I can't seem to
figure this out. Can someone let me know how to go about doing this? Thanks.

Marie
 
I have created an autoexec macro that runs every time the database is
opened. However, I only want the macro to run just once daily. I know that
there is a way to do this by running code attached to autoexec that checks
if the macro has been run and updates a field in a table with the date
that
the macro ran and checks it against todays date and does not run again
until
the following day. I don't know how to write code, and I can't seem to
figure this out. Can someone let me know how to go about doing this?
Thanks.

If you don't know how to write code, your *best course of action* is to get
a copy of the "Access Developer's Handbook" for your version of Access,
published by Sybex. Try out all the VBA code examples. What you're asking
would require tutorials that are WAY too long to post here.

--
Peace & happy computing,

Mike Labosh, MCSD

"When you kill a man, you're a murderer.
Kill many, and you're a conqueror.
Kill them all and you're a god." -- Dave Mustane
 
Here is a macro that shows a message box if the date has changed.

------
Version =196611
ColumnsShown =2
Begin
Condition
="[application].[DBEngine](0)(0).[Containers](\"databases\").[Documents](\"UserDef"
"ined\").[Properties](\"mydate\")<>Date()"
Action ="MsgBox"
Argument ="false"
Argument ="-1"
Argument ="0"
End
Begin
Condition ="..."
Action ="SetValue"
Comment
="DBEngine(0)(0).Containers(\"databases\").Documents(\"UserDefined\").Properties(\""
"mydate\")"
Argument
="[application].[DBEngine](0)(0).[Containers](\"databases\").[Documents](\"UserDef"
"ined\").[Properties](\"mydate\")"
Argument ="Date()"
End
------

You may use any action or series of actions instead of the msgbox.
Each following action should have the condition "...". The last
action is to set the database property to today's date.

You need to create the database property (File,Database Properties, Custom)
and give it a starting value before you do this.

(david)
 
Back
Top