M
mike
Hi. I have a procedure that sends emails out to some
people here. The code is behind a form. On the form are a
clock and four controls called SendEast, SendCentral,
SendMountain, SendWest. The controls are defaulted to
6:00:00 AM, 7:00:00 AM, 8:00:00 AM, 9:00:00 AM,
respectively. When the clock strikes any of those numbers,
code runs that sends to a message to people in that time
zone.
It runs great if I only have code behind the form that
sends to people at 6AM, for example, but if I copy that
code and paste it in to send at 7,8,9 then Access says my
code is too large. The code is almost identical so i could
probably break it up into modules but I'm not sure how.
Here's how my code looks:
Private Sub Form_Timer()
Me.Clock = Format(Now, "h:nn:ss AM/PM")
If Me.Clock = Me!SENDEAST Then
Set Db = CurrentDb
Set rs = Db.OpenRecordset("SELECT * " & _
"FROM [qryMain]" & _
"WHERE [SendTIME]=#6:00:00 AM#")
If Not rs.EOF Then
Do While Not rs.EOF
....there's a whole bunch of code in here at this point
that works fine so I won't repeat it here, but this is
what's causing the problem. It's the same exact code for
the procedure that executes at 7,8, and 9 so I was hoping
to store the code in a module and look it up instead of
having it sitting here...
DoCmd.SendObject acSendNoObject, , , rs!EmailAddress, , ,
Subject, Message, False
rs.MoveNext
Loop
End If
End If
THEN I REPEAT BUT USE THE SENDCENTRAL CONTROL ON MY FORM
TO TRIGGER THE PROCEDURE AND FILTER MY RECORDSET BY
[SendTIME]=#7:00:00 AM#".
If Me.Clock = Me!SENDCENTRAL Then
Set Db = CurrentDb
Set rs = Db.OpenRecordset("SELECT * " & _
"FROM [qryMain]" & _
"WHERE [SendTIME]=#7:00:00 AM#")
If Not rs.EOF Then
Do While Not rs.EOF
....there's a whole bunch of code in here that works fine
so I won't repeat it here...
DoCmd.SendObject acSendNoObject, , , rs!EmailAddress, , ,
Subject, Message, False
rs.MoveNext
Loop
End If
End If
End Sub
people here. The code is behind a form. On the form are a
clock and four controls called SendEast, SendCentral,
SendMountain, SendWest. The controls are defaulted to
6:00:00 AM, 7:00:00 AM, 8:00:00 AM, 9:00:00 AM,
respectively. When the clock strikes any of those numbers,
code runs that sends to a message to people in that time
zone.
It runs great if I only have code behind the form that
sends to people at 6AM, for example, but if I copy that
code and paste it in to send at 7,8,9 then Access says my
code is too large. The code is almost identical so i could
probably break it up into modules but I'm not sure how.
Here's how my code looks:
Private Sub Form_Timer()
Me.Clock = Format(Now, "h:nn:ss AM/PM")
If Me.Clock = Me!SENDEAST Then
Set Db = CurrentDb
Set rs = Db.OpenRecordset("SELECT * " & _
"FROM [qryMain]" & _
"WHERE [SendTIME]=#6:00:00 AM#")
If Not rs.EOF Then
Do While Not rs.EOF
....there's a whole bunch of code in here at this point
that works fine so I won't repeat it here, but this is
what's causing the problem. It's the same exact code for
the procedure that executes at 7,8, and 9 so I was hoping
to store the code in a module and look it up instead of
having it sitting here...
DoCmd.SendObject acSendNoObject, , , rs!EmailAddress, , ,
Subject, Message, False
rs.MoveNext
Loop
End If
End If
THEN I REPEAT BUT USE THE SENDCENTRAL CONTROL ON MY FORM
TO TRIGGER THE PROCEDURE AND FILTER MY RECORDSET BY
[SendTIME]=#7:00:00 AM#".
If Me.Clock = Me!SENDCENTRAL Then
Set Db = CurrentDb
Set rs = Db.OpenRecordset("SELECT * " & _
"FROM [qryMain]" & _
"WHERE [SendTIME]=#7:00:00 AM#")
If Not rs.EOF Then
Do While Not rs.EOF
....there's a whole bunch of code in here that works fine
so I won't repeat it here...
DoCmd.SendObject acSendNoObject, , , rs!EmailAddress, , ,
Subject, Message, False
rs.MoveNext
Loop
End If
End If
End Sub