VBA Date Looping

  • Thread starter a0a349 via AccessMonster.com
  • Start date
A

a0a349 via AccessMonster.com

I have the following code in a form (timer) used for scheduled databases.
This works when there is only 1 macro that needs to be run.
Private Sub Form_Timer()

If Format(Now(), "medium time") = Me.UpdateTime Then
DoCmd.RunMacro "mcrRun_Data-Monthly"
End If

End Sub

I have a few databases that need to run 2 or more macros based on the time of
year.
For example: If the "Month = 3 (March)", I need macros "mcrRun_Data-Monthly"
AND "mcrRun_Data-Monthly1" to run.

I have figured out a way to update my table of Dates for this scenario (IIf(
[Month]=1,DateSerial(Year(Date())-1,7,1),IIf(Date()<DateAdd("m",6,DateSerial
(Year(Date()),1,1)),DateSerial(Year(Date()),1,1),DateSerial(Year(Date()),7,1))
)), but my VBA skills are not strong (I usually ask for help on code).

Any assistance is greatly appreciated!
Jen
 
D

Douglas J. Steele

Private Sub Form_Timer()

If Format(Now(), "medium time") = Me.UpdateTime Then
DoCmd.RunMacro "mcrRun_Data-Monthly"
If Month(Date) = 3 Then
DoCmd.RunMacro "mcrRun_Data-Monthly1"
End If
End If

End Sub
 
A

a0a349 via AccessMonster.com

So simple! THANK YOU!
Private Sub Form_Timer()

If Format(Now(), "medium time") = Me.UpdateTime Then
DoCmd.RunMacro "mcrRun_Data-Monthly"
If Month(Date) = 3 Then
DoCmd.RunMacro "mcrRun_Data-Monthly1"
End If
End If

End Sub
I have the following code in a form (timer) used for scheduled databases.
This works when there is only 1 macro that needs to be run.
[quoted text clipped - 21 lines]
Any assistance is greatly appreciated!
Jen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top