Solved

Updated Calendar and Subform

Posted on 2014-02-17
2
318 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
2 Comments
 
LVL 35

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

821 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