Code Help

  • Thread starter Thread starter Bgreer5050
  • Start date Start date
B

Bgreer5050

I am looking to create the following event. When a form loads I would like
it to email me a file at home every 2 hours. I know how to handle the email
part, I just do not know how to handle the code to monitor the time and or
create a timer that counts and executes the send code when reached.

Thanks for any help.
 
For a long interval like 2 hours, you would be best to store the time the
report was last emailed in a table. Otherwise, is the form is opened, then
closed and opened again, you will get two copies in quick succession.

Create a table with one record and two fields: ReportEmailInterval (numeric,
long) and ReportLastEmailed (date/time). Of course, you can add other
fields to this table to store other "global settings". Set
ReportEmailInterval to 120 (minutes).

Now, set the TimerInterval of your form to 60,000 (one minute). In the
Form_Timer event procedure, open a recordset on your GlobalSettings table
and check:

If DateAdd( "n", rst!ReportEmailInterval, rst!ReportLastEmailed) < Now
Then
' send your email
rst.Edit
rst!ReportLastEmailed = Now
rst.Update
End If
 
I would use the On Timer event of the forms property. The Timer interval is
in milliseconds so Two hours would be 72,000,000 if my math is right.
 
Back
Top