UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Outlook Update, Access 2013    
 
   
waitingroomz
post Jun 18 2019, 03:45 PM
Post#1



Posts: 93
Joined: 29-October 18



Below is a code that I am using to either create an appointment or find and update an appointment using the GlobalAppointmentID.

The error handler is feeding me "Error #440 Cannot parse condition, error at [strGlobalID]"

Anyone care to look what I'm doing wrong?

CODE
Public Function OutlookAction(ActionID As eOutlookAction, Optional strOLGlobalID)
Set objOLApp = CreateObject("Outlook.Application")
Set objOLNameSpace = objOLApp.GetNamespace("MAPI")
Set objOLFolder = objOLNameSpace.GetDefaultFolder(9).Items
Set dbOL = CurrentDb
Select Case ActionID
    Case NewAppt
        Set objOLAppt = objOLApp.CreateItem(1)
        Set rsOL = dbOL.OpenRecordset("tblOutlookItems")
        GetDistroList Ret
            With objOLAppt
                .MeetingStatus = 1
                .Start = datStart
                .End = datEnd
                .Subject = UCase(strApptSubj)
                .Location = strApptLoc
                .RequiredAttendees = Ret
                .Save
                strOLGlobalID = .GlobalAppointmentID
            End With
            subGetUserInfo
            With rsOL
                rsOL.AddNew
                rsOL!ApptStart = datStart
                rsOL!ApptEnd = datEnd
                rsOL!Subject = strApptSubj
                rsOL!Location = strApptLoc
                rsOL!DateCreated = Now
                rsOL!CreatedBy = strUserName
                rsOL!GlobalApptID = strOLGlobalID
                rsOL.Update
            End With
        Set rsOL = Nothing
    Case UpdAppt
        strFind = "GlobalAppointmentID= " & strOLGlobalID
        Set objOLItem = objOLFolder.Find(strFind)
        If Not objOLItem Is Nothing Then
            strMsg = objOLItem.Subject & vbCrLf & vbCrLf & objOLItem.Start & _
            vbCrLf & vbCrLf & objOLItem.End & vbCrLf & vbCrLf & objOLItem.Location & vbCrLf & vbCrLf & "Found"
            MsgBox strMsg, vbOKOnly
        Else
        MsgBox "Not Found"
        End If
        Set objOLItem = Nothing
End Select
Set dbOL = Nothing
End Function
Go to the top of the page
 
theDBguy
post Jun 18 2019, 03:46 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,405
Joined: 19-June 07
From: SunnySandyEggo


What does strGlobalID (or is it strOLGlobalID?) look like when you get the error?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
waitingroomz
post Jun 19 2019, 07:01 AM
Post#3



Posts: 93
Joined: 29-October 18



So strOLGlobalID on the error Message shows:

Error # 440
Cannot parse condition. Error at
"C5B7101A82E008000000001063FF6DF025D50100..."

On the event calling the Function I have:

CODE
strOLGlobalID = Me.txtTest
Debug.Print strOLGlobalID
OutlookAction UpdAppt, strOLGlobalID


When it Debug.Print shows, it reads as "040000008200E00074C5B7101A82E008000000001063FF6DF025D5010000000000000000100
000008D37549DCF56F74F8138F6994DF282DD"
Go to the top of the page
 
ADezii
post Jun 19 2019, 12:39 PM
Post#4



Posts: 2,679
Joined: 4-February 07
From: USA, Florida, Delray Beach


  1. Do to its inherent nature, you cannot perform a Find Operation on the GlobalAppointmentID Property of an Appointment Item.
  2. What you can do, for an Update Operation, is to:
    1. Create a Public Procedure that will accept a GlobalAppointmentID (STRING) as its only Argument.
    2. Loop thru all Appointments until the Appointment whose GlobalAppointmentID matches that of the Routine's Argument is found.
    3. Once found, change some Properties of the Appointment. In this Demo I changed the Subject, Body, and kept the Location the same just for illustration purposes.
    4. Save the Updated Appointment.
    5. Exit the Sub-Routine.
  3. If the Appointment is not found, notify the User of same.
  4. Code Definition (tested and operational):
    CODE
    Public Sub UpdateAppointment(strGUID As String)
    Dim appOut As Outlook.Application
    Dim objNS As Outlook.Namespace
    Dim objAppointment As Outlook.AppointmentItem
    Dim objFldr As Outlook.MAPIFolder

    Set appOut = New Outlook.Application
    Set objNS = Outlook.GetNamespace("MAPI")
    Set objFldr = objNS.GetDefaultFolder(olFolderCalendar)

    For Each objAppointment In objFldr.Items
      With objAppointment
        If .GlobalAppointmentID = strGUID Then
          .Subject = "Cancellation of Staff Meeting"
          .Location = "Lecture Hall A"
          .Body = "The scheduled Staff Meeting for today has been cancelled and " & _
                  "will be rescheduled at a later date."
          .Save
           Exit Sub
        End If
      End With
    Next


    'If you get to this point, the Appointment was not found
    MsgBox "An Appointment with ID " & strGUID & " was not found!", _
            vbExclamation, "Not Fouond"
    End Sub
  5. Sample Call to Sub-Routine:
    CODE
    Call UpdateAppointment("040000008200E00074C5B7101A82E00800000000D08613F29B26D50100000000000000001000
    0000593A784FBD282E4AB26BE0226D74B5EF")
  6. Hope this helps.

P.S. - Not exactly the ideal solution, but a solution just the same.
This post has been edited by ADezii: Jun 19 2019, 12:41 PM
Go to the top of the page
 
waitingroomz
post Jun 19 2019, 03:46 PM
Post#5



Posts: 93
Joined: 29-October 18



I'll have to try this in the morning, thank you!
Go to the top of the page
 
ADezii
post Jun 20 2019, 05:38 AM
Post#6



Posts: 2,679
Joined: 4-February 07
From: USA, Florida, Delray Beach


yw.gif
Go to the top of the page
 
waitingroomz
post Jun 20 2019, 08:01 AM
Post#7



Posts: 93
Joined: 29-October 18



I'm late-binding.

How would I do this for Outlook.AppointmentItem? The olObjectClass enumeration is 26.
Go to the top of the page
 
ADezii
post Jun 20 2019, 09:38 AM
Post#8



Posts: 2,679
Joined: 4-February 07
From: USA, Florida, Delray Beach


The Late Binding equivalent would be:
CODE
Public Sub UpdateAppointment_LateBind(strGUID As String)
Dim appOut As Object
Dim objNS As Object
Dim objAppointment As Object
Dim objFldr As Object
Const conCALENDAR = 9

Set appOut = CreateObject("Outlook.Application")
Set objNS = appOut.GetNamespace("MAPI")
Set objFldr = objNS.GetDefaultFolder(conCALENDAR)

For Each objAppointment In objFldr.Items
  With objAppointment
    If .GlobalAppointmentID = strGUID Then
      .Subject = "Cancellation of Staff Meeting"
      .Location = "Lecture Hall A"
      .Body = "The scheduled Staff Meeting for today has been cancelled and " & _
              "will be rescheduled at a later date."
      .Save
       Exit Sub
    End If
  End With
Next

'If you get to this point, the Appointment was not found
MsgBox "An Appointment with ID " & strGUID & " was not found!", _
        vbExclamation, "Not Fouond"
End Sub

This post has been edited by ADezii: Jun 20 2019, 09:38 AM
Go to the top of the page
 
waitingroomz
post Jun 20 2019, 01:46 PM
Post#9



Posts: 93
Joined: 29-October 18



You sir, are a fantastic individual.

*applauds*
Go to the top of the page
 
ADezii
post Jun 20 2019, 02:01 PM
Post#10



Posts: 2,679
Joined: 4-February 07
From: USA, Florida, Delray Beach


I assume that all went well? laugh.gif
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th October 2019 - 03:41 AM