Solved

Updated Calendar and Subform

Posted on 2014-02-17
2
315 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 34

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Explanation of Access VBA code 2 35
Why can't I get my report to SORT correctly? 5 26
DSum for Access 6 42
Keeping a combo box up to date for other users 5 22
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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

943 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now