Private Sub not working on main form

P

Perplexed

I have the following code input for an event procedure on a subform and it
works fine. If I ignore and cancel the email I can hit the "end" button and
move to the next record in the database.

Private Sub Form_Current()
If [CDLExpires] <= Date + 60 Then

DoCmd.SendObject acSendNoObject, , , To:="myemail@address", Subject:="Action
Needed", MessageText:="Employee: " & Forms.employees.FirstName & " " &
Forms.employees.LastName & vbCrLf & vbCrLf & "CDL Expires: " & [CDLExpires]
& vbCrLf & vbCrLf & "Please schedule appropriate appts with DMV",
EditMessage:=True
Else
End If

If [MedicalExpires] <= Date + 60 Then

DoCmd.SendObject acSendNoObject, , , To:="myemail@address", Subject:="Action
Needed", MessageText:="Employee: " & Forms.employees.FirstName & " " &
Forms.employees.LastName & vbCrLf & vbCrLf & "Medical Expires: " &
[MedicalExpires] & vbCrLf & vbCrLf & "Please schedule appt with Doctor",
EditMessage:=True
Else
End If

If [VTT] <= Date + 60 Or [GPPV] <= Date + 60 Then

DoCmd.SendObject acSendNoObject, , , To:="myemail@address", Subject:="Action
Needed", MessageText:="Employee: " & Forms.employees.FirstName & " " &
Forms.employees.LastName & vbCrLf & vbCrLf & "VTT Expires: " & [VTT] &
vbCrLf & vbCrLf & "GPPV Expires: " & [GPPV] & vbCrLf & vbCrLf & "Please
schedule appt with DMV ", EditMessage:=True
Else
End If
End Sub

However, when I enter similar code to just one above for a specific field in
the main form it goes into a continous loop and won't end or go to next
record. Sometimes it doesn't work at all. Is there a difference in entering
code in the main form for event procedures?

Thanks!
 
C

Clifford Bass

Hi,

No difference. However, if you have On Current events for both the
main form and the subform, you will get calls to each whenever you move to a
new main record. You could test what is happening by displaying message
boxes in various places. So maybe at the beginning of each you could do
something like:

MsgBox "Entering [your form's name] Form_Current"

Add other messages in other places if you wish to help narrow things
down. Then test it out, see what happens and when.

Or you could set some break points and trace through the code. Search
for "trace" or "tracing" in your online help for details.

Clifford Bass
 

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

Similar Threads


Top