![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I'm not getting a subroutine to return the correct counts based on using
the Restrict method. Is it because I am passing the wrong date format? If I pass a comparison: Received = Date1 And Date2, I get all recs greater/equal date1. If I only want records for Date1, I get 0 records. Received = Date1 If I want all records =1 date, I get correct count. Received = Date1 Below I show the call to the subroutine and by routine. Any clue what I am doing wrong? Thanks for any advice. RestrictItems _ "00000000F01460E0716E454B8398DD735E95C4CA82800000" , _ "2/24/2010", "2/25/2010" Sub RestrictItems(strEntryID As String, _ strDate1 As String, strDate2 As String) Dim olApp As Object Dim olNS As Object Dim olFolders As Object Dim olItems As Object Dim olMailItem As Object Dim olRestrict As Object Set olApp = GetObject(, "Outlook.Application") Set olNS = olApp.GetNamespace("MAPI") Set olFolders = _ olApp.GetNamespace("Mapi").GetFolderFromID(strEntr yID) Set olItems = olFolders.Items '1. this line returns all items from both dates. Incorrect Set olRestrict = olItems.Restrict("[CreationTime] = """ _ & strDate1 & """ And [ReceivedTime] """ & strDate2 & """") '2. this line returns 0. Incorrect Set olRestrict = olItems.Restrict("[CreationTime] = """ & _ strDate1 & """") '3. this line returns all items from both dates. Correct Set olRestrict = olItems.Restrict("[CreationTime] = """ _ & strDate1 & """") 'used for all 3 options/comparisons MsgBox "Count is " & olRestrict.Count End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Restrict() method and Null values | Craig Buchanan[_2_] | Add-ins for Outlook | 3 | December 16th 08 04:04 PM |
Restrict Method - Find only blank fields - VBA | Irene | Outlook and VBA | 1 | June 5th 07 04:25 PM |
Using Restrict method to select emails | Jerry West | Outlook and VBA | 16 | April 26th 07 05:48 PM |
Restrict method problem | Mike Epp | Outlook and VBA | 2 | April 7th 06 07:03 PM |
Restrict Method DNW | emanson | Outlook and VBA | 14 | March 28th 06 05:47 AM |