Restrict Method DNW

G

Guest

Any idea why the following does not work (Returns all items in collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn AMPM") &
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest] to no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
M

Michael Bauer

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn
 
G

Guest

Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of [FlagRequest] I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

Michael Bauer said:
Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Any idea why the following does not work (Returns all items in collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn AMPM") &
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest] to no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
M

Michael Bauer

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of [FlagRequest] I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

Michael Bauer said:
Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Any idea why the following does not work (Returns all items in collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest] to no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
G

Guest

Adding myItms.IncludeRecurrences = False had no effect. I am unable to get
the restrict method to work with any field/condition is it possible that this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

Michael Bauer said:
Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of [FlagRequest] I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

Michael Bauer said:
Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest] to no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
M

Michael Bauer

Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Adding myItms.IncludeRecurrences = False had no effect. I am unable to get
the restrict method to work with any field/condition is it possible that this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

Michael Bauer said:
Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of
[FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest]
to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
G

Guest

I do not receive an error message. The following is the format I use for date:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict method
to work at all but with no luck. It thinks for a second and then returns all
items in the collection no matter what condition I set.

Thanks!
Ed
Michael Bauer said:
Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Adding myItms.IncludeRecurrences = False had no effect. I am unable to get
the restrict method to work with any field/condition is it possible that this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

Michael Bauer said:
Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of [FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest] to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
G

Guest

See above for date format. I do nto receive an error message. I have tried
many different conditions in the restrict method but no matter what
conditions I set the method returtns all members from the collection.

Thanks!
Ed

Michael Bauer said:
Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Adding myItms.IncludeRecurrences = False had no effect. I am unable to get
the restrict method to work with any field/condition is it possible that this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

Michael Bauer said:
Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of [FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest] to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
M

Michael Bauer

Am Thu, 23 Mar 2006 06:18:30 -0800 schrieb emanson:


What values do DateTo and DateFrom contain? Did you try to count the result
as suggested instead of reading the Count property?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

I do not receive an error message. The following is the format I use for date:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict method
to work at all but with no luck. It thinks for a second and then returns all
items in the collection no matter what condition I set.

Thanks!
Ed
Michael Bauer said:
Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Adding myItms.IncludeRecurrences = False had no effect. I am unable to get
the restrict method to work with any field/condition is it possible that this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

:

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of [FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried the
above using [ReceivedTime] rather than my user defined [FlagRequest] to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
G

Guest

DateFrom >= "2/1/2006 12:00 AM"
DateTo < "2/3/2006 12:00 AM"

I know it is pulling in all records because I have to use a supplementary
conditonal within the For Each loop to filter out emails that are erroneously
included:

If CDate(itm.FlagRequest) >= CDate(DateFrom) And CDate(itm.FlagRequest) <
CDate(DateAdd("d", 1, DateTo)) Then


Thanks!
Ed

Michael Bauer said:
Am Thu, 23 Mar 2006 06:18:30 -0800 schrieb emanson:


What values do DateTo and DateFrom contain? Did you try to count the result
as suggested instead of reading the Count property?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

I do not receive an error message. The following is the format I use for date:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict method
to work at all but with no luck. It thinks for a second and then returns all
items in the collection no matter what condition I set.

Thanks!
Ed
Michael Bauer said:
Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Adding myItms.IncludeRecurrences = False had no effect. I am unable to
get
the restrict method to work with any field/condition is it possible that
this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

:

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter
should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to
loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of
[FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried
the
above using [ReceivedTime] rather than my user defined [FlagRequest]
to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
M

Michael Bauer

Am Thu, 23 Mar 2006 10:15:35 -0800 schrieb emanson:

So far that all seems to be ok. Just for being sure here is a function that
works:

Public Function RestrictDateSpan(colItems As Outlook.Items, _
dtFrom As Date, _
dtTo As Date _
) As Outlook.Items
On Error Resume Next
Dim colResult As Outlook.Items
Dim sFilter As String
Dim sFrom As String
Dim sTo As String

colItems.Sort "[ReceivedTime]"
colItems.IncludeRecurrences = True
sFrom = Quote(Format(dtTo, "ddddd") & " 11:59 PM")
sTo = Quote(Format(dtFrom, "ddddd") & " 12:00 AM")
sFilter = "[ReceivedTime] <= " & sFrom & " AND [ReceivedTime] > " & sTo
Set colResult = colItems.Restrict(sFilter)
Set RestrictDateSpan = colResult
End Function

Private Function Quote(sText As String) As String
Quote = Chr(34) & sText & Chr(34)
End Function


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

DateFrom >= "2/1/2006 12:00 AM"
DateTo < "2/3/2006 12:00 AM"

I know it is pulling in all records because I have to use a supplementary
conditonal within the For Each loop to filter out emails that are erroneously
included:

If CDate(itm.FlagRequest) >= CDate(DateFrom) And CDate(itm.FlagRequest) <
CDate(DateAdd("d", 1, DateTo)) Then


Thanks!
Ed

Michael Bauer said:
Am Thu, 23 Mar 2006 06:18:30 -0800 schrieb emanson:


What values do DateTo and DateFrom contain? Did you try to count the result
as suggested instead of reading the Count property?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

I do not receive an error message. The following is the format I use
for
date:
strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict method
to work at all but with no luck. It thinks for a second and then
returns
all
items in the collection no matter what condition I set.

Thanks!
Ed
:

Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Adding myItms.IncludeRecurrences = False had no effect. I am unable to
get
the restrict method to work with any field/condition is it possible that
this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

:

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter
should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to
loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1, DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of
[FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom, "ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried
the
above using [ReceivedTime] rather than my user defined [FlagRequest]
to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
G

Guest

Using this function had no effect. It is still returning all items in the
collection.

Thanks!
Ed

Michael Bauer said:
Am Thu, 23 Mar 2006 10:15:35 -0800 schrieb emanson:

So far that all seems to be ok. Just for being sure here is a function that
works:

Public Function RestrictDateSpan(colItems As Outlook.Items, _
dtFrom As Date, _
dtTo As Date _
) As Outlook.Items
On Error Resume Next
Dim colResult As Outlook.Items
Dim sFilter As String
Dim sFrom As String
Dim sTo As String

colItems.Sort "[ReceivedTime]"
colItems.IncludeRecurrences = True
sFrom = Quote(Format(dtTo, "ddddd") & " 11:59 PM")
sTo = Quote(Format(dtFrom, "ddddd") & " 12:00 AM")
sFilter = "[ReceivedTime] <= " & sFrom & " AND [ReceivedTime] > " & sTo
Set colResult = colItems.Restrict(sFilter)
Set RestrictDateSpan = colResult
End Function

Private Function Quote(sText As String) As String
Quote = Chr(34) & sText & Chr(34)
End Function


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

DateFrom >= "2/1/2006 12:00 AM"
DateTo < "2/3/2006 12:00 AM"

I know it is pulling in all records because I have to use a supplementary
conditonal within the For Each loop to filter out emails that are erroneously
included:

If CDate(itm.FlagRequest) >= CDate(DateFrom) And CDate(itm.FlagRequest) <
CDate(DateAdd("d", 1, DateTo)) Then


Thanks!
Ed

Michael Bauer said:
Am Thu, 23 Mar 2006 06:18:30 -0800 schrieb emanson:


What values do DateTo and DateFrom contain? Did you try to count the result
as suggested instead of reading the Count property?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I do not receive an error message. The following is the format I use for
date:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict method
to work at all but with no luck. It thinks for a second and then returns
all
items in the collection no matter what condition I set.

Thanks!
Ed
:

Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Adding myItms.IncludeRecurrences = False had no effect. I am unable to
get
the restrict method to work with any field/condition is it possible that
this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

:

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter
should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you
set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to
loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1,
DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of
[FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried
the
above using [ReceivedTime] rather than my user defined [FlagRequest]
to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
M

Michael Bauer

Am Sun, 26 Mar 2006 14:45:28 -0800 schrieb emanson:

i don´t believe that. Please try that function for a *build in date field*,
e.g. ReceivedTime for e-mails or Start for appointments.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Using this function had no effect. It is still returning all items in the
collection.

Thanks!
Ed

Michael Bauer said:
Am Thu, 23 Mar 2006 10:15:35 -0800 schrieb emanson:

So far that all seems to be ok. Just for being sure here is a function that
works:

Public Function RestrictDateSpan(colItems As Outlook.Items, _
dtFrom As Date, _
dtTo As Date _
) As Outlook.Items
On Error Resume Next
Dim colResult As Outlook.Items
Dim sFilter As String
Dim sFrom As String
Dim sTo As String

colItems.Sort "[ReceivedTime]"
colItems.IncludeRecurrences = True
sFrom = Quote(Format(dtTo, "ddddd") & " 11:59 PM")
sTo = Quote(Format(dtFrom, "ddddd") & " 12:00 AM")
sFilter = "[ReceivedTime] <= " & sFrom & " AND [ReceivedTime] > " & sTo
Set colResult = colItems.Restrict(sFilter)
Set RestrictDateSpan = colResult
End Function

Private Function Quote(sText As String) As String
Quote = Chr(34) & sText & Chr(34)
End Function


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

DateFrom >= "2/1/2006 12:00 AM"
DateTo < "2/3/2006 12:00 AM"

I know it is pulling in all records because I have to use a supplementary
conditonal within the For Each loop to filter out emails that are erroneously
included:

If CDate(itm.FlagRequest) >= CDate(DateFrom) And CDate(itm.FlagRequest) <
CDate(DateAdd("d", 1, DateTo)) Then


Thanks!
Ed

:

Am Thu, 23 Mar 2006 06:18:30 -0800 schrieb emanson:


What values do DateTo and DateFrom contain? Did you try to count the result
as suggested instead of reading the Count property?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I do not receive an error message. The following is the format I use for
date:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict method
to work at all but with no luck. It thinks for a second and then returns
all
items in the collection no matter what condition I set.

Thanks!
Ed
:

Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Adding myItms.IncludeRecurrences = False had no effect. I am unable to
get
the restrict method to work with any field/condition is it possible that
this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

:

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter
should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you
set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to
loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1,
DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of
[FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also tried
the
above using [ReceivedTime] rather than my user defined [FlagRequest]
to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
G

Guest

the following is waht I used:

Public Function RestrictDateSpan(colItems, DateFrom, DateTo) As Outlook.Items
On Error Resume Next
Dim colResult As Outlook.Items
Dim sFilter As String
Dim sFrom As String
Dim sTo As String

colItems.Sort "[ReceivedTime]"
colItems.IncludeRecurrences = True
sFrom = Quote(Format(DateFrom, "ddddd") & " 11:59 PM")
sTo = Quote(Format(DateTo, "ddddd") & " 12:00 AM")
sFilter = "[ReceivedTime] <= " & sFrom & " AND [ReceivedTime] > " & sTo
Set colResult = colItems.Restrict(sFilter)
Set RestrictDateSpan = colResult
End Function

The function returns all items in folder collection.

Thanks!
Ed

The restrict function is
Michael Bauer said:
Am Sun, 26 Mar 2006 14:45:28 -0800 schrieb emanson:

i don´t believe that. Please try that function for a *build in date field*,
e.g. ReceivedTime for e-mails or Start for appointments.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Using this function had no effect. It is still returning all items in the
collection.

Thanks!
Ed

Michael Bauer said:
Am Thu, 23 Mar 2006 10:15:35 -0800 schrieb emanson:

So far that all seems to be ok. Just for being sure here is a function that
works:

Public Function RestrictDateSpan(colItems As Outlook.Items, _
dtFrom As Date, _
dtTo As Date _
) As Outlook.Items
On Error Resume Next
Dim colResult As Outlook.Items
Dim sFilter As String
Dim sFrom As String
Dim sTo As String

colItems.Sort "[ReceivedTime]"
colItems.IncludeRecurrences = True
sFrom = Quote(Format(dtTo, "ddddd") & " 11:59 PM")
sTo = Quote(Format(dtFrom, "ddddd") & " 12:00 AM")
sFilter = "[ReceivedTime] <= " & sFrom & " AND [ReceivedTime] > " & sTo
Set colResult = colItems.Restrict(sFilter)
Set RestrictDateSpan = colResult
End Function

Private Function Quote(sText As String) As String
Quote = Chr(34) & sText & Chr(34)
End Function


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


DateFrom >= "2/1/2006 12:00 AM"
DateTo < "2/3/2006 12:00 AM"

I know it is pulling in all records because I have to use a supplementary
conditonal within the For Each loop to filter out emails that are
erroneously
included:

If CDate(itm.FlagRequest) >= CDate(DateFrom) And CDate(itm.FlagRequest) <
CDate(DateAdd("d", 1, DateTo)) Then


Thanks!
Ed

:

Am Thu, 23 Mar 2006 06:18:30 -0800 schrieb emanson:


What values do DateTo and DateFrom contain? Did you try to count the
result
as suggested instead of reading the Count property?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I do not receive an error message. The following is the format I use
for
date:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict
method
to work at all but with no luck. It thinks for a second and then
returns
all
items in the collection no matter what condition I set.

Thanks!
Ed
:

Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Adding myItms.IncludeRecurrences = False had no effect. I am unable
to
get
the restrict method to work with any field/condition is it possible
that
this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

:

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter
should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you
set
IncludeRecurrences=True.

In that case if you need to know the number of items then you need to
loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1,
DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) &
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of
[FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in
this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd
h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also
tried
the
above using [ReceivedTime] rather than my user defined
[FlagRequest]
to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 
M

Michael Bauer

Am Mon, 27 Mar 2006 07:16:03 -0800 schrieb emanson:

I suppose that´s it:

- Using the function below
a) you don´t check colResult but colItems for the results and
b) you don´t look in an e-mail folder (as suggested for ReceivedTime)

If you comment out the On Error statement then you will probably get an
error saying that "ReceivedTime" is unknown.

Restrict works only if the field is known in that folder. For userdefined
fields that means: If the field is unknown to the folder then create a new
dummy message, add the field (also to the folder) and delete the message
again. Now the folder knows the field and you can use it in Restrict.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

the following is waht I used:

Public Function RestrictDateSpan(colItems, DateFrom, DateTo) As Outlook.Items
On Error Resume Next
Dim colResult As Outlook.Items
Dim sFilter As String
Dim sFrom As String
Dim sTo As String

colItems.Sort "[ReceivedTime]"
colItems.IncludeRecurrences = True
sFrom = Quote(Format(DateFrom, "ddddd") & " 11:59 PM")
sTo = Quote(Format(DateTo, "ddddd") & " 12:00 AM")
sFilter = "[ReceivedTime] <= " & sFrom & " AND [ReceivedTime] > " & sTo
Set colResult = colItems.Restrict(sFilter)
Set RestrictDateSpan = colResult
End Function

The function returns all items in folder collection.

Thanks!
Ed

The restrict function is
Michael Bauer said:
Am Sun, 26 Mar 2006 14:45:28 -0800 schrieb emanson:

i don´t believe that. Please try that function for a *build in date field*,
e.g. ReceivedTime for e-mails or Start for appointments.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Using this function had no effect. It is still returning all items in the
collection.

Thanks!
Ed

:

Am Thu, 23 Mar 2006 10:15:35 -0800 schrieb emanson:

So far that all seems to be ok. Just for being sure here is a function that
works:

Public Function RestrictDateSpan(colItems As Outlook.Items, _
dtFrom As Date, _
dtTo As Date _
) As Outlook.Items
On Error Resume Next
Dim colResult As Outlook.Items
Dim sFilter As String
Dim sFrom As String
Dim sTo As String

colItems.Sort "[ReceivedTime]"
colItems.IncludeRecurrences = True
sFrom = Quote(Format(dtTo, "ddddd") & " 11:59 PM")
sTo = Quote(Format(dtFrom, "ddddd") & " 12:00 AM")
sFilter = "[ReceivedTime] <= " & sFrom & " AND [ReceivedTime] > " & sTo
Set colResult = colItems.Restrict(sFilter)
Set RestrictDateSpan = colResult
End Function

Private Function Quote(sText As String) As String
Quote = Chr(34) & sText & Chr(34)
End Function


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


DateFrom >= "2/1/2006 12:00 AM"
DateTo < "2/3/2006 12:00 AM"

I know it is pulling in all records because I have to use a supplementary
conditonal within the For Each loop to filter out emails that are
erroneously
included:

If CDate(itm.FlagRequest) >= CDate(DateFrom) And
CDate(itm.FlagRequest)
<
CDate(DateAdd("d", 1, DateTo)) Then


Thanks!
Ed

:

Am Thu, 23 Mar 2006 06:18:30 -0800 schrieb emanson:


What values do DateTo and DateFrom contain? Did you try to count the
result
as suggested instead of reading the Count property?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I do not receive an error message. The following is the format I use
for
date:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd h:nn
AMPM") & Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd h:nn AMPM") & Chr(34)

I have tried many other conditions to see if I can get the Restrict
method
to work at all but with no luck. It thinks for a second and then
returns
all
items in the collection no matter what condition I set.

Thanks!
Ed
:

Am Wed, 22 Mar 2006 10:01:28 -0800 schrieb emanson:

Do you get an error message? What format has the field?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Adding myItms.IncludeRecurrences = False had no effect. I am unable
to
get
the restrict method to work with any field/condition is it possible
that
this
may be an issue with the version/environment?

Thanks Michael for you help,

Ed

:

Am Wed, 22 Mar 2006 07:36:30 -0800 schrieb emanson:

Sorry, my fault. I didn´t read your first post carefully. The filter
should
be ok.

That all items are returned, i.e. Count = 2147483647, happens if you
set
IncludeRecurrences=True.

In that case if you need to know the number of items then you
need
to
loop
through the result and count them:

Dim obj as Object
Dim i as Long
For Each obj in myItems
i=i+1
Next


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael -

I changed strFind to the following:

strFind = "[FlagRequest] < " & Chr(34) & Format(DateAdd("d", 1,
DateTo),
"yyyy.mm.dd hh:nn") & Chr(34) & " AND [FlagRequest] >= " &
Chr(34)
&
Format(DateFrom, "yyyy.mm.dd hh:nn") & Chr(34)

still no luck. When I tried using [ReceivedTime] instead of
[FlagRequest]
I
trapped the following formatting error: type mismatch or the
"2006.02.03 00:00" is not valid. Any ideas?

Thanks!
Ed

:

Am Tue, 21 Mar 2006 10:56:32 -0800 schrieb emanson:

If FlagRequest is a DateTime field then the values are stored in
this
format: yyyy.mm.dd hh:nn


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Any idea why the following does not work (Returns all items in
collection):

strFind = "[FlagRequest] < " & Chr(34) & Format(DateTo, "ddddd
h:nn
AMPM")
&
Chr(34) & " AND [FlagRequest] >= " & Chr(34) & Format(DateFrom,
"ddddd
h:nn
AMPM") & Chr(34)
Set myItms = objFolder.Items
Set myItms = myItms.Restrict(strFind)

Please let me know if you need more information. I have also
tried
the
above using [ReceivedTime] rather than my user defined
[FlagRequest]
to
no
avail. Any help would be greatly appreciated.

Thanks!
Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top