Filtering uncategorized items

  • Thread starter Thread starter Terence Patterson
  • Start date Start date
T

Terence Patterson

Hi there folks.

This is causing me a surprising amount of grief. I'm working on an
application that uses the Outlook View Control (Outlook XP) to view
the items in various Outlook folders based on their Categories.
Restricting the items to those that have specific Categories assigned
is no problem. I'm setting the .Restriction property of the control
to the appropriate criteria string, such as:
"[Categories]='<mycategory>'"
or
"[Categories]=""<mycategory>"""
- (interpreted as [Categories]="<mycategory>")

What I can't seem to get is the correct criteria syntax to limit the
view to UNCATEGORIZED items. I've tried the following:
"[Categories]=''"
and
"[Categories]="""""
- (interpreted as [Categories]="")
I've also tried experimenting with VB- and SQL-type keywords such as:
"[Categories] IS NULL"
and
"[Categories] IS EMPTY"

Is there a syntax detail or a keyword I'm missing here? Is there a
better way to do this, perhaps using the .ViewXML property? Any help
would be appreciated.

Thanks in advance.
- Terry
 
Hi Ken. Thanks for replying to my post.

Your suggestion inspired me to build a criteria string based on the
"[Categories]<>'<mycategory>'" approach. I need to exclude several
categories, so I created a function that builds a string in the format
"[Categories]<>'<mycategory1>' AND [Categories]<>'<mycategory2>' AND
[Categories]<>'<mycategory3>' ... AND [Categories]<>'<mycategory-n>'"

Unfortunately, I need to exclude over 100 Category strings and this
approach caused an error indicating that the criteria string was too
complex.

Any other ideas?
Thanks again.
- Terry
 
You could do multiple restrictions. Assign the results of the first
one to an Items collection and then another restriction on the second
Items collection. Repeat until you have used all your clauses. You
will have to experiment to see how many clauses you can include in 1
restriction before you start getting errors.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Terence Patterson said:
Hi Ken. Thanks for replying to my post.

Your suggestion inspired me to build a criteria string based on the
"[Categories]<>'<mycategory>'" approach. I need to exclude several
categories, so I created a function that builds a string in the format
"[Categories]<>'<mycategory1>' AND [Categories]<>'<mycategory2>' AND
[Categories]<>'<mycategory3>' ... AND
 
Thanks once again, Ken. I'm not quite following your suggestion here.
Is it possible to assign an Items collection to the Outlook View
Control? Or are you suggesting something completely different?

I tried using the .Filter property and got almost-ideal results with
the value:
("DAV:isfolder" = false AND "DAV:ishidden" = false) AND
("urn:schemas-microsoft-com:office:office#Keywords" IS NULL)

However, this technique brought up another problem during cleanup. If
I reset the control's .Filter property to the default value of:
"DAV:isfolder" = false AND "DAV:ishidden" = false
The view is properly restored except the 'Filter Applied' message
still appears when viewing the folder in Outlook. When I look at the
View details, the DASL Filter is still turned on. Do you know any way
to progammatically turn it off? If I can get the cleanup issue
resolved, I think this would be the solution I'm looking for.

Thanks again in advance.
- Terry
 
Sorry, I forgot you are using the OVC. That's one of the really bad
things about interfaces to the newsgroups that don't post part of the
preceding thread. In that case you cannot assign an Items collection
as I suggested.

I'm not sure about clearing the filter, I don't work with the OVC very
often at all. I'd suggest searching at Slipstick and on the MSDN site
for information about that.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
Back
Top