Access 2010 Multiple executions on load

aattas

Registered User.
Local time
Today, 14:39
Joined
Dec 24, 2014
Messages
75
Experts,
Need some help.
I have a program that runs an autoemail when the form is loaded. All are fine except the autoemail keep running everytime i load the form. Is there a code that I put behind the " ON-LOAD" where it should run only one time.
or a code that I can say stop running the autoemail after the first execution.
Appreciate your help.
 
I would store a date value in a table and compare that date value against the today's value when the form open.
If it not equal, send the mail and store the today's value in that table.
 
Hi JHB, thankyou very much for your response , but not being that expert this is my code, where do i put your suggestion as im using by day name.

Private Sub Form_Load()
If Weekday(Date) = vbTuesday Or vbWednesday Then
Call GenerateEmail(" SELECT * FROM qryDuein7days")


Thanks
 
Create a table with 1 field, call the field RunLastTime, field type DateTime, save the table and call it FormRunLastDate
Code:
Private Sub Form_Load()
  Dim rst As DAO.Recordset
  
  Set rst = CurrentDb.OpenRecordset("FormRunLastDate")
  If rst.EOF Then 'No date in the table yet, therefor add date
    rst.AddNew
    rst![RunLastTime] = Date
    rst.Update
    'Call your procedure for sending mail here below
  Else
    If rst![RunLastTime] <> Date Then
      rst.Edit
      rst![RunLastTime] = Date
      rst.Update
      'Call your procedure for sending mail here below
    End If
  End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom