Adding Date Autofill To Existing Coding (1 Viewer)

ledmark

Ledmark
Local time
Today, 08:48
Joined
Mar 11, 2008
Messages
127
Hello! I'm having some technical difficulties and would love your expertise - I have a form built where there is a date field in one section that has the date of the request put in it called ProjectDate. Then in another section for following up I have it set up so that an e-mail address is entered then the next field is the date for the follow-up call (FUDateContacted) - when this is entered it generates an e-mail that goes to the sales person on the date the follow-up call is to be made. That works perfectly.

The customer is now asking if the follow-up date can be automatically filled in to be 4 days after the request date. I know there is coding that needs to be added to the existing coding but I have no idea how it should go. Here is the coding to make the e-mail get sent when the follow-up date is entered:

Private Sub FUDateContacted_AfterUpdate()
Dim appOutLook As Object
Dim MailOutLook As Object

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
.To = Me.EmailRecipient 'get the recipient from the form
.Subject = "Project ID:" & Me.ID & ", Street Ref: " & Me.ClientStreet 'get the street and ID from the form
.body = "This is a reminder that you need to make a follow up call to the address in the Subject line today."
.DeferredDeliveryTime = Me.FUDateContacted 'get the date from the form

.Send
End With

Set appOutLook = Nothing
Set MailOutLook = Nothing
End Sub

How can I have this field look at the ProjectDate field and add four days to it and then have the follow-up e-mail sent on the calculated date?

Thanks tons for any help :)

Laura
 

DCrake

Remembered
Local time
Today, 16:48
Joined
Jun 8, 2005
Messages
8,626
You can use the DateAdd() function to add 4 days to the initial date

FUDate = DateAdd("d",4,FirstDate)
 

ledmark

Ledmark
Local time
Today, 08:48
Joined
Mar 11, 2008
Messages
127
OK - I feel like a dummy but where in the coding would I put that line or would it go someplace else?
 

DCrake

Remembered
Local time
Today, 16:48
Joined
Jun 8, 2005
Messages
8,626
Code:
.DeferredDeliveryTime = DateAdd("d",4,  Me.FUDateContacted )
 

ledmark

Ledmark
Local time
Today, 08:48
Joined
Mar 11, 2008
Messages
127
OK - I'm seeing it and I'll give it a whirl soon. I'll let you know what happens - thank you tons!
 

ledmark

Ledmark
Local time
Today, 08:48
Joined
Mar 11, 2008
Messages
127
OK - I put in the line you gave me:

.deferredDeliveryTime = DateAdd("d",4, Me.FUDateContacted)

This did nothing so I changed it to this thinking it didn't know what to look at to add the 4 days:

.DeferredDeliveryTime = DateAdd("Me.ProjectDate", 4, Me.FUDateContacted) 'get the date from the form

Still it did nothing. Is the DateAdd function supposed to make it look at the ProjectDate when it's entered and then when the focus comes to the FUDateContacted it add four days to the ProjectDate automatically?

Do I put FUDateContacted = DateAdd("d",4,ProjectDate) anywhere in the coding?

Laura
 

ledmark

Ledmark
Local time
Today, 08:48
Joined
Mar 11, 2008
Messages
127
I'm reading about the DateAdd function and it is always referring to a query but I'm working on a form and when I put in the ProjectDate then tab down to enter the e-mail address and then when I tab tot he FUDateContacted I want it to automatically add 4 days to the Project date and fill the FUDateContacted field. The DateAdd function is not working here - it looks like when I tab to the FUDateContaced field it doesn't know where to look to add the four days. Should it maybe look like this:

.DeferredDeliveryTime = DateAdd("d", 4, Me.ProjectDate) 'get the date from the form

I'm feel like there is something missing and I can't figure out what it is.
 

Users who are viewing this thread

Top Bottom