Solved

Updated Calendar and Subform

Posted on 2014-02-17
2
321 Views
Last Modified: 2014-02-17
We have a subform "CustomerQuotes" which sits within Main Form "JobReports". When a customer quote is generated it has a "status" field that defaults to "In Progress". This is then updated to Accepted", "Declined" etc.

The field "generateddate" is populated when a new record is raised.

I am using the following code to put a calendar entry into Outlook if the customer quote status has no changed from "In Progress" after  7 Days.

The code is triggered from the Load Event of the JobReports Form.

The idea of the sevendayreminder is that this is populated when the calendar reminder is sent., so that it will not be resent every time the form is loaded.

My problem is where do I put the code so that both actions take place?

      Dim objApp As Object
    Dim objNS As Object
    Dim objFolder As Object
    Dim objDummy As Object
    Dim objRecip As Object
    Dim objAppt As Object
    Dim strMsg As String
    Dim strName As String
    Dim strSubject As String

           
    On Error Resume Next
strSubject = DLookup("[ID]", "[CustomerQuote]", "[Status] = 'In Progress' and [generateddate] < Now() -7 and [sevendayreminder] Is Null")
    strName = "User"
     
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    Set objDummy = objApp.CreateItem(0)
    Set objRecip = objDummy.Recipients.Add(strName)
    objRecip.Resolve

    If objRecip.Resolved Then
        On Error Resume Next
        Set objFolder = _
          objNS.GetSharedDefaultFolder(objRecip, _
            9)
         
        If Not objFolder Is Nothing Then
            Set objAppt = objFolder.Items.Add
                   If DLookup("[generateddate]", "[CustomerQuote]", "[Status] = 'In Progress' and [generateddate] < Now() -7 and [generateddate] > Now() -14 and [sevendayreminder] Is Null") Then
       
           
           If Not objAppt Is Nothing Then
                With objAppt
         
                      .Subject = strSubject
                      .body = Forms![Job Reports]!CustomerQuote!Purpose
                    .Start = Now() + 7
                    .alldayevent = True
                    .Save
                End With
                End If
            End If
            End If
    Else
        MsgBox "Could not find " & Chr(34) & strName & Chr(34), , _
               "User not found"
    End If
                              If DLookup("[generateddate]", "[CustomerQuote]", "[Status] = 'In Progress' and [generateddate] < Now() -7 and [generateddate] > Now() -14 and [sevendayreminder] Is Null") Then
Forms![Job Reports]![CustomerQuotes]!SevenDayReminder = Forms!frmdatabaselogin!cboStaffMember
End If

    Set objApp = Nothing
    Set objNS = Nothing
    Set objFolder = Nothing
    Set objDummy = Nothing
    Set objRecip = Nothing
    Set objAppt = Nothing
0
Comment
Question by:SparkyP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 37

Accepted Solution

by:
PatHartman earned 500 total points
ID: 39865083
You would have to put the code in the Open event of your login or main menu form.  It needs to go some place where the user isn't going to have to click on something to make it happen.  As long as the user opens the app within the time period, using the login or main menu will make the entry in Outlook.

PS - I didn't examine the code to see if it would work.
0
 

Author Closing Comment

by:SparkyP
ID: 39866651
Just what I wanted

Many Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question