Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lookup Calendar Item (2000)

    Good afternoon,

    We have vba code to insert an appointment item in an outlook calendar, which is working well.

    Is there a way that before inserting the appointment item, it can check to ensure it is not going to 'double book' with another items already in the calendar?
    Best Regards,

    Luke

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

    Re: Lookup Calendar Item (2000)

    There are some examples of looking for appointments within a certain date/time range:

    <post#=514,951>post 514,951</post#> (this is in the Outlook forum, but it can be run from Access)
    <post#=465,155>post 465,155</post#>
    The threads starting at <post#=459,906>post 459,906</post#> and <post#=460,236>post 460,236</post#> (although the second one is rather long and confusing)

    You can adapt these to look for appointments that would conflict with the one you want to create.

  3. #3
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup Calendar Item (2000)

    Thanks for these, working a treat.

    I am slightly stuck on the final section:

    Set curAppt = olAppts.Find("[Start] = """ & strStart & _
    """ And [End] = """ & strEnd & """")

    I want to basically determine if the start date and time conflicts with an 'already busy' period. So I assume I need to look at something like:

    Set curAppt = olAppts.Find("[Start] = """ & strStart & _
    """ And [STATUS] = """ & "Busy" & """")

    Any ideas?
    Best Regards,

    Luke

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

    Re: Lookup Calendar Item (2000)

    You need to look for appointments that start before the end of the new appointment and end after the start of the new appointment. And Status isn't a property of an appointment. Appointments have a property BusyStatus that can be olFree = 0, olTentative = 1, olOutOfOffice = 3 and olBusy = 4. So you want to look for appointments that have BusyStatus > 1

    Try
    <code>
    Set curAppt = olAppts.Find(("[Start] < """ & strStart & _
    """ And [End] > """ & strStart & """ And [BusyStatus] > 1")</code>

  5. #5
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup Calendar Item (2000)

    I have the line:

    Set curAppt = olAppts.Find(("[Start] < """ & strStart & """ And [End] > """ & strStart & """ And [BusyStatus] > 1")

    It comes up with a syntax error. Any ideas?
    Best Regards,

    Luke

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

    Re: Lookup Calendar Item (2000)

    I included a superfluous second opening parenthesis (. Try removing one of the two.

  7. #7
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup Calendar Item (2000)

    All done and all sorted .... almost.

    The only problem I find is that it does not pick up 'Recurring events' up a slot already taken despite the time being allocated as being 'busy'.

    Any ideas?
    Best Regards,

    Luke

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

    Re: Lookup Calendar Item (2000)

    See the thread starting at <post:=460,236>post 460,236</post:> (mentioned higher up in this thread), it explains how to deal with recurring appointments.

    BTW, it would be much easier to let the user create appointments directly in the Outlook calendar, of course.

Posting Permissions

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