Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static Boolean Trouble!

Status
Not open for further replies.

mike1975

IS-IT--Management
Jun 26, 2001
38
GB
I am using the code below to run a report every wednesday, I would really like the report to run every Wednesday and Thursday at say 19:00 hours. Any help as to how to ammend this code would be helpful.


dim MyDate,MyWeekday
static bSent as boolean

MyDate=Date
MyWeekday = Weekday(MyDate, vbUseSystemDayOfWeek)
If ((MyWeekday = 3) And (bSent=False))Then
DoCmd.SendObject acSendReport, "Support Request Log Query", acFormatSNP, "mikeharris", , , "Pending Report", False
bSent = True
End If


Any help would be great

Many thanks - MIKE
 
Not sure what you are looking for. Is it how to run the code on Wed and Thur instead of just Wed, or is it to do with the code not working, if so, how is it not working?
Have fun! :eek:)

Alex Middleton
 
Thanks Alex,

The code works fine just stuck on how to add that tantalising next stage!!

MIKE
 
The only way you are going to get this to run automatically, is to set it up on a timer event of a form.

Set the Timer Interval on a form that is open 24/7 (if you don't have one, create a small form and make it hidden), to 300000 (5 minutes (1 second = 1000)).

Now on the Timer Event, put the following code:

=======================
Private Sub Form_Timer()
If (WeekDay(Date) = 4 Or WeekDay(Date) = 5) And (TIME > #7:00:00 PM# And TIME < #7:04:59 PM#) Then
DoCmd.SendObject acSendReport, &quot;Support Request Log Query&quot;, acFormatSNP, &quot;mikeharris&quot;, , , &quot;Pending Report&quot;, False
End If
End Sub
=======================

This code will be run every five minutes, but the SendObject command will only be fired every Wed or Thur between 7:00:00 pm and 7:04:59 pm. Jim Lunde
compugeeks@hotmail.com
We all agree your theory is crazy, but is it crazy enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top