# Counting Appointments

Status
Not open for further replies.
B

#### baggers

Hi Guys

I'm trying to count the number of appointments in a calendar using the

restrict method.

If I add "items.IncludeRecurrences = True" then the numbers returned all

equal 2147483647.

Here is a code snippet:

dateFrom = Date.Today

dateTo = CDate("2014-01-01")

strFind = "[Start] >= " & DoubleQuote(Format(dateFrom, "dd MMM yyyy")) & "

AND [Start] < " & DoubleQuote(Format(dateTo, "dd MMM yyyy"))

items = mapi.GetFolderFromID(sID).Items

items.Sort("[Start]")

items.IncludeRecurrences = True

restrictedItems = items.Restrict(strFind)

itemCounter = itemCounter + restrictedItems.Count

can anyone see where the problem lies?

Thanks

That's a known side effect of using IncludeRecurrences: Count isn't

meaningful. To get an accurate count, you can loop through the filtered

Items collection in a For Each ... Next loop and increment a counter

variable on each pass.

Sue Mosher

"baggers" <simon.baguley@npbs.co.uk> wrote in message

> Hi Guys
> I'm trying to count the number of appointments in a calendar using the
> restrict method.
> If I add "items.IncludeRecurrences = True" then the numbers returned all
> equal 2147483647.

> Here is a code snippet:
> dateFrom = Date.Today
> dateTo = CDate("2014-01-01")
> strFind = "[Start] >= " & DoubleQuote(Format(dateFrom, "dd MMM yyyy")) & "
> AND [Start] < " & DoubleQuote(Format(dateTo, "dd MMM yyyy"))
> items = mapi.GetFolderFromID(sID).Items
> items.Sort("[Start]")
> items.IncludeRecurrences = True
> restrictedItems = items.Restrict(strFind)
> itemCounter = itemCounter + restrictedItems.Count

> can anyone see where the problem lies?

> Thanks
>

Sue

Thanks for that answer, it explains why I was getting strange numbers.

The method you suggest is terribly slow (we have multiple calendars in which

there are recurring appointments with no end date).

Do you know of a quicker way to get the number of appointments between two

specific dates?

Thanks

Simon.

"Sue Mosher [MVP]" wrote:

> That's a known side effect of using IncludeRecurrences: Count isn't
> meaningful. To get an accurate count, you can loop through the filtered
> Items collection in a For Each ... Next loop and increment a counter
> variable on each pass.
> > Sue Mosher
> > >

> "baggers" <simon.baguley@npbs.co.uk> wrote in message
> > Hi Guys
> > I'm trying to count the number of appointments in a calendar using the
> > restrict method.
> > If I add "items.IncludeRecurrences = True" then the numbers returned all
> > equal 2147483647.
> > Here is a code snippet:
> > dateFrom = Date.Today
> > dateTo = CDate("2014-01-01")
> > strFind = "[Start] >= " & DoubleQuote(Format(dateFrom, "dd MMM yyyy")) & "
> > AND [Start] < " & DoubleQuote(Format(dateTo, "dd MMM yyyy"))
> > items = mapi.GetFolderFromID(sID).Items
> > items.Sort("[Start]")
> > items.IncludeRecurrences = True
> > restrictedItems = items.Restrict(strFind)
> > itemCounter = itemCounter + restrictedItems.Count
> > can anyone see where the problem lies?
> > Thanks
> >

>

Status
Not open for further replies.
Thread starter Title Forum Replies Date
Counting and/or listing fired reminders via VBA Using Outlook 1
Outlook 365 New Appointments All saved to a 365 default calendar on Mac Using Outlook 0
New Calendar Appointments: Conditionally turn off reminder and show time as free Using Outlook 5
Outlook Calendar deleted appointments not in Deleted Items folder Using Outlook 3
Outlook 2021 all appointments not showing in calendar Using Outlook 2
Changing colors of today's appointments, but not recurring ones Using Outlook 33
Printing Appointments Using Outlook 1
Calendar daily Appointments and printing Using Outlook 0
Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
Option to Show Cancelled Appointments Using Outlook 0
Export Outlook calendar appointments by filters and date range Outlook VBA and Custom Forms 1
Outlook 2007 only loads some appointments Using Outlook 0
Gathering Calendar Appointments from Calendars that synced as Contacts Exchange Server Administration 1
Year-and-a-day recurring appointments Using Outlook 1
what file contains contacts, tasks and appointments stored locally? Using Outlook 1
hiding appointments that are completed or cancelled, how to ? Using Outlook 5
warning for too many appointments on a same day in Outlook Using Outlook 1
importing appointments to non-default calendar? Using Outlook 1
Appointments Using Outlook 0
Make past appointments remain in calendar Using Outlook 1
Creating Outlook Appointments from Excel Cells Outlook VBA and Custom Forms 1
Outlook.com changing appointments Using Outlook 8
populate calendar with appointments and send reminders Using Outlook 1
Copy New Appointments to Another Calendar using VBA Using Outlook 0
Create Appointments Using Spreadsheet Data Using Outlook 0
How to Import Appointments into a Group Calendar Using Outlook 0
Outlook 2013 Appointments not in HTML Using Outlook.com accounts in Outlook 2
Appointments Created in iCloud Calendars Cover Contacts Field...Why? Using Outlook 3
Expected behaviour of recurring appointments? Using Outlook 2
Find all deleted recurrence appointments Outlook VBA and Custom Forms 4
Copy new appointments created in multiple shared calendars to another exchange calendar Outlook VBA and Custom Forms 1
Outlook calendar appointments Free/Busy time is changing from "Busy" to "Free" Using Outlook 2
Outlook does not show new appointments in To-Do-Bar Using Outlook 0
Looping appointments in calendar Outlook VBA and Custom Forms 0
Outlook Calendar/setting appointments Using Outlook 1
Appointments disappearing Using Outlook 0
To do bar - show more than 30 days of appointments Using Outlook 0
Show ALL of today's appointments in To-Do Bar Using Outlook 1
Outlook 2007 Calendar Appointments not in Outlook Today view Using Outlook 11
Can't stop Outlook.com from setting reminders on appointments? Using Outlook.com accounts in Outlook 3
Outlook 2013 Appointments missing Using Outlook 1
Outlook Shared appointments automatically to Private Calendar Using Outlook 1
Synchronize Access Table with Outlook Calendar Appointments Outlook VBA and Custom Forms 3
Change reminder times of future appointments Using Outlook 1
Search folder for appointments and emails Using Outlook 2
Appointments from Excel to Outlook Using Outlook 3
Appointments Using Outlook 25
Appointments Exchange Server Administration 4
Adding appointments/tasks to other user's calendar Using Outlook 1
Getting a colleagues appointments and calendar entries Using Outlook 1