Run a Macro on a given date.

Modesto157

New member
Local time
Today, 00:30
Joined
Jan 21, 2005
Messages
2
I need to run a macro on a given date. For example, I need on 10/30/2005 for a specific macro to run.

I though to create a VBA or module, that checks every time the data base is open to see if the date is equal to 10/30/2005 or greater if it is, I need the Macro to run. If the date has not being reached then the macro is not ran.

How difficult would it be to create this VBA or module?

Can anyone help me in creating this VBA or module?

Thanks!
 
You should have a switchboard form or some kind of form that opens when the database is opened.

OnOpen property of that form put this

Code:
If Date = #10/30/2005# Then

DoCmd.RunMacro "MacroNameHere"

End If

However, remember that the date is hard coded so once the macro has run then it'll need to be changed, so what do you do then?

You may be better off having a hidden field on the opening form so you can change the date easily there - the code would then refer to that field

Code:
If Date = Me.DateFieldHere Then

DoCmd.RunMacro "MacroNameHere"

End If

Col
 
Col,

Thanks... that is exactly what I was looking for....
 
Just had another thought. Bear in mind that the code above will run every time the database is opened on that day.

Assuming you want the macro to run only once - and you go for the hidden field option, you can use the fields "tag" property to indicate the macro has run. Check the value of the tag and change it in the VB script when the macro has run.

Col
 

Users who are viewing this thread

Back
Top Bottom