My code...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is wrong with this code? Can you help?

Private Sub Form_Open(Cancel As Integer)

If Date = DateAdd("d", -10, Me.DueDate) Then
MsgBox "The reminder mail will now be sent", vbOKOnly, "E Mail Due"

DoCmd.SendObject acReport, "CDRLReport", "RichTextFormat(*.rtf)",
Forms!frmContractInfo Mainform!PMemailAddress,
Forms!frmContractInfo Mainform, , "", "A CDRL is Due in 10 Days", "Please
submit your CDRL by the due date", False, ""

End If
End Sub

Thanks a lot.
 
Hi again

I gave you that code and it is my fault for assumeing that you understand
it. Sorry.

When you have an "if" you need also a "Then", "Else" (in some cases), and an
"End If".

The code should be (you can cut and paste if the names are correct)
____________________________________

Private Sub Form_Open(Cancel As Integer)
If Date = DateAdd("d", -10, Me.DueDate) Then
MsgBox "The reminder mail will now be sent", vbOKOnly, "E Mail Due"
Else
DoCmd.SendObject acReport, "CDRLReport", "RichTextFormat(*.rtf)", _
Forms!frmContractInfo Mainform!PMemailAddress, _
Forms!frmContractInfo Mainform, , "", _
"A CDRL is Due in 10 Days", "Please submit your CDRL by the due date",
False, ""
End If
End Sub
____________________________________


The reason for this
You can say IF some thing is true THEN ..... whatever
If it is not true (ELSE)......
and then finish the whole thing with a END IF

Note I have have added ELSE to the code above.
Also note that this forum can messup code with the size of the page.

All this should go on 1 line

DoCmd.SendObject acReport, "CDRLReport", "RichTextFormat(*.rtf)",
Forms!frmContractInfo Mainform!PMemailAddress,
Forms!frmContractInfo Mainform, , "",
"A CDRL is Due in 10 Days", "Please submit your CDRL by the due date",
False, ""

Unless you use the underscore after a space (like this _) which I have
added to the code so you can just cut and paste.



Let me know if you have any problems.
 
Thanks Wayne, I'll give it a shot and let you know how it turns out. Thanks
for all your help.

Freehal
 
I just realized that my duedate appears on a subform of the form I'm trying
to get my code to work on. Is there a way to reconcile this?
 
Back
Top