?
Solved

Updated Calendar and Subform

Posted on 2014-02-17
2
Medium Priority
?
322 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 38

Accepted Solution

by:
PatHartman earned 2000 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Suggested Courses

770 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