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
 
S

Sue Mosher [MVP]

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

news:93AF81E8-42E7-4C5A-8AD8-BB4C641DA8B9@microsoft.com...
> 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
>
 
B

baggers

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
> news:93AF81E8-42E7-4C5A-8AD8-BB4C641DA8B9@microsoft.com...
> > 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.
Similar threads
Thread starter Title Forum Replies Date
S Changing colors of today's appointments, but not recurring ones Using Outlook 33
M Printing Appointments Using Outlook 1
M Calendar daily Appointments and printing Using Outlook 0
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
L Option to Show Cancelled Appointments Using Outlook 0
O Export Outlook calendar appointments by filters and date range Outlook VBA and Custom Forms 1
R Outlook 2007 only loads some appointments Using Outlook 0
N Gathering Calendar Appointments from Calendars that synced as Contacts Exchange Server Administration 1
F Year-and-a-day recurring appointments Using Outlook 1
J what file contains contacts, tasks and appointments stored locally? Using Outlook 1
D hiding appointments that are completed or cancelled, how to ? Using Outlook 5
M warning for too many appointments on a same day in Outlook Using Outlook 1
V importing appointments to non-default calendar? Using Outlook 1
OutlookIntegrator Appointments Using Outlook 0
R Make past appointments remain in calendar Using Outlook 1
M Creating Outlook Appointments from Excel Cells Outlook VBA and Custom Forms 1
A Outlook.com changing appointments Using Outlook 8
T populate calendar with appointments and send reminders Using Outlook 1
Diane Poremsky Copy New Appointments to Another Calendar using VBA Using Outlook 0
Diane Poremsky Create Appointments Using Spreadsheet Data Using Outlook 0
Diane Poremsky How to Import Appointments into a Group Calendar Using Outlook 0
I Outlook 2013 Appointments not in HTML Using Outlook.com accounts in Outlook 2
makinmyway Appointments Created in iCloud Calendars Cover Contacts Field...Why? Using Outlook 3
M Expected behaviour of recurring appointments? Using Outlook 2
C Find all deleted recurrence appointments Outlook VBA and Custom Forms 4
M Copy new appointments created in multiple shared calendars to another exchange calendar Outlook VBA and Custom Forms 1
R Outlook calendar appointments Free/Busy time is changing from "Busy" to "Free" Using Outlook 2
G Outlook does not show new appointments in To-Do-Bar Using Outlook 0
A Looping appointments in calendar Outlook VBA and Custom Forms 0
B Outlook Calendar/setting appointments Using Outlook 1
L Appointments disappearing Using Outlook 0
N To do bar - show more than 30 days of appointments Using Outlook 0
A Show ALL of today's appointments in To-Do Bar Using Outlook 1
F Outlook 2007 Calendar Appointments not in Outlook Today view Using Outlook 11
A Can't stop Outlook.com from setting reminders on appointments? Using Outlook.com accounts in Outlook 3
S Outlook 2013 Appointments missing Using Outlook 1
N Outlook Shared appointments automatically to Private Calendar Using Outlook 1
A Synchronize Access Table with Outlook Calendar Appointments Outlook VBA and Custom Forms 3
J Change reminder times of future appointments Using Outlook 1
Mark Rideout Search folder for appointments and emails Using Outlook 2
C Appointments from Excel to Outlook Using Outlook 3
C Appointments Using Outlook 25
C Appointments Exchange Server Administration 4
I Adding appointments/tasks to other user's calendar Using Outlook 1
R Getting a colleagues appointments and calendar entries Using Outlook 1
N Outlook 2010 Archived Appointments Missing Using Outlook 5
Katrina Fox Missing appointments on calendar even though transferred from old pst Using Outlook 0
Horsepower Setting appointments in calendar Using Outlook 3
W Outlook 2010 - Displaying Private Appointments In Shared Calendars Using Outlook 1
T Synchronize outlook appointments through web application. Using Outlook 1

Similar threads

Top