Results 1 to 12 of 12
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding appointments to Outlook (win XP Of 2003)

    I am trying to add appointments to Outlook from Access, and it appears that Knowledge Base Art 209963 fits well with what I want to do. I am having trouble with the sample code. The reminder dates are in 2003, and no appointments show up, although the code runs to completion.

    I don't understand the lines .PatternStartDate and .PatternEndDate.

    Here is the .mdb. Could you give me some guidence?
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    The part of the code from

    Set objRecurPattern = .GetRecurrencePattern

    to the first End With below it makes the appointment into a recurring appointment. It occurs once a week, starting at 7/22/2003 (PatternStartDate) and ending at 7/23/2003 (PatternEndDate). This overrides the Start date set earlier, and the code creates an appointment for July 22, 2003 - at least, I got one (and was immediately reminded that it was 279 weeks overdue <img src=/S/grin.gif border=0 alt=grin width=15 height=15>)

    If you don't want to create a recurring appointment, remove or comment out the part of the code mentioned above. The code will then create an appointment for November 11, 2008, the Start date set from the ApptDate text box.

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    That did it! Thank you!

  4. #4
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    How can I avert overwriting a previous appointment? The previous appointment could or could not have been set with this routine. If the appointment was set by the routine, there is a record in the table, but it only shows the initial appointment and not possible additional appointments using the interval specified.

    Can you give me some ideas, please?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    The code always creates a new appointment, it won't overwrite existing ones.

  6. #6
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    My example duplicates the appointment, and shows them side-be-side in the Outlook calendar.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    Apparently I interpreted "overwrite" differently than you.

    Here is a function that you can use to test whether there is already an appointment with the specified start and end:
    <code>
    Function AppointmentExists(dtStart As Date, dtEnd As Date) As Boolean
    Dim olApplication As Outlook.Application
    Dim olNsp As Outlook.NameSpace
    Dim strStart As String
    Dim strEnd As String
    Dim olAppts As Outlook.Items
    Dim curAppt As Outlook.AppointmentItem

    On Error GoTo ErrHandler

    Set olApplication = CreateObject("Outlook.Application")
    Set olNsp = olApplication.GetNamespace("MAPI")
    strStart = Format(dtStart, "mm/dd/yyyy hh:mm AM/PM")
    strEnd = Format(dtEnd, "mm/dd/yyyy hh:mm AM/PM")

    Set olAppts = olNsp.GetDefaultFolder(olFolderCalendar).Items
    Set curAppt = olAppts.Find("<!t>[Start]<!/t> = """ & strStart & _
    """ And <!t>[End]<!/t> = """ & strEnd & """")
    AppointmentExists = Not curAppt Is Nothing

    ExitHandler:
    Set olAppts = Nothing
    Set olNsp = Nothing
    Set olApplication = Nothing
    Exit Function

    ErrHandler:
    MsgBox Err.Number & " " & Err.Description, vbExclamation
    Resume ExitHandler
    End Function
    </code>
    You can use it like this:
    <code>
    If AppointmentExists(Me.ApptDate + Me.ApptTime, DateAdd("n", Me.ApptLength, Me.ApptDate + Me.ApptTime) = True Then
    MsgBox "The calendar already contains an appointment for this time!", vbExclamation
    Else
    ...
    End If</code>

  8. #8
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    This is getting complicated.

    I added a form to pick up the starting and ending dates, and the length of the appointments.

    When I check for conflicts in an appointment, the code recognizes as a conflict two appointments with the same start date and length. If the start date is the same, but the length is different, there is no conflict, and the code adds the new appointment. There is no awareness of appointments beyond the first date. I have played with changing the parameters for OutlookAppointments to pick up the ending date, but no help. I donít understand the Set curAppt statement.

    Could I show a conflict based only on the range of start date/end date, and not include the appointment length?
    Attached Files Attached Files

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    What exactly do you want to accomplish? Do you want to entirely avoid overlapping appointments?

  10. #10
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    I will start a trial use of the code, as is, tomorrow. That should give me a better idea. I would like to be sure that a conflicting appointment on the first day of the series will not be allowed. That gives me the trouble of same starting dates and times, but different lengths, not being interpreted as a conflict. Can that be fixed?

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    See if you can adapt some of the code from the thread starting at <post:=460,236>post 460,236</post:>.

  12. #12
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding appointments to Outlook (win XP Of 2003)

    We are up and running satisfactorily. It was a good education. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •