Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Restrict() method and Null values

Geek News

Restrict() method and Null values
"Craig Buchanan" <someone[ at ]microsoft.com> 12/16/2008 4:11:43 AM
I am trying to get a list of contacts (using the Restict() method) in a
Outlook 2003 Contact folder that do NOT have an Email1Address assigned.

These (Jet?) queries do NOT eliminate contacts without an Email1Address:

[Email1Address] <> ''
NOT([Email1Address] = '')
NOT([Email1Address] IS NULL) 'plus lower-case variations
"[Email1Address]<>" & Chr(34) & Chr(34)

Email1Address that are missing are considered Nothing in the Immediate
window, btw.

I'm using .Net framework 2.0. I am testing in Offline mode, if that makes a
difference.

Can someone shed some light on this for me?

Thanks,

Craig Buchanan


Re: Restrict() method and Null values
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 12/16/2008 2:29:55 PM
You can use a DASL query for that using the undocumented "[ at ]SQL=" prefix.
Using that syntax your query for only items with an Email1Address would look
like this in VB.NET:

Dim sFilter As String = "[ at ]SQL=NOT(urn:schemas:contacts:email1 IS NULL)"

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Craig Buchanan" <someone[ at ]microsoft.com> wrote in message
news:u3ZUoRzXJHA.5272[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
>I am trying to get a list of contacts (using the Restict() method) in a
>Outlook 2003 Contact folder that do NOT have an Email1Address assigned.
>
> These (Jet?) queries do NOT eliminate contacts without an Email1Address:
>
> [Email1Address] <> ''
> NOT([Email1Address] = '')
> NOT([Email1Address] IS NULL) 'plus lower-case variations
> "[Email1Address]<>" & Chr(34) & Chr(34)
>
> Email1Address that are missing are considered Nothing in the Immediate
> window, btw.
>
> I'm using .Net framework 2.0. I am testing in Offline mode, if that makes
> a difference.
>
> Can someone shed some light on this for me?
>
> Thanks,
>
> Craig Buchanan
>

Re: Restrict() method and Null values
Craig Buchanan 12/16/2008 3:48:09 PM
Ken-

Thanks for the reply.

Why don't Jet queries support IS NULL or <>''?

Thanks,

Craig

"Ken Slovak - [MVP - Outlook]" wrote:

[Quoted Text]
> You can use a DASL query for that using the undocumented "[ at ]SQL=" prefix.
> Using that syntax your query for only items with an Email1Address would look
> like this in VB.NET:
>
> Dim sFilter As String = "[ at ]SQL=NOT(urn:schemas:contacts:email1 IS NULL)"
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "Craig Buchanan" <someone[ at ]microsoft.com> wrote in message
> news:u3ZUoRzXJHA.5272[ at ]TK2MSFTNGP04.phx.gbl...
> >I am trying to get a list of contacts (using the Restict() method) in a
> >Outlook 2003 Contact folder that do NOT have an Email1Address assigned.
> >
> > These (Jet?) queries do NOT eliminate contacts without an Email1Address:
> >
> > [Email1Address] <> ''
> > NOT([Email1Address] = '')
> > NOT([Email1Address] IS NULL) 'plus lower-case variations
> > "[Email1Address]<>" & Chr(34) & Chr(34)
> >
> > Email1Address that are missing are considered Nothing in the Immediate
> > window, btw.
> >
> > I'm using .Net framework 2.0. I am testing in Offline mode, if that makes
> > a difference.
> >
> > Can someone shed some light on this for me?
> >
> > Thanks,
> >
> > Craig Buchanan
> >
>
>
Re: Restrict() method and Null values
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 12/16/2008 4:04:54 PM
Why's the sky blue? <g>

Jet queries do support that sort of thing and in VBA code I'd use something
like this:

"[Email1Address] <>" & Chr(34) & Chr(34)

However in .NET code I've found many cases where a property is not there
even if in VBA code it would be null string. It might be null string or null
(Nothing) in .NET code. So for me it's a lot easier to avoid that possible
problem and to just use DASL syntax for the search. Personal preference plus
some experience.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Craig Buchanan" <CraigBuchanan[ at ]discussions.microsoft.com> wrote in message
news:264D85FD-FDCC-4B36-A466-78F69A82EE15[ at ]microsoft.com...
[Quoted Text]
> Ken-
>
> Thanks for the reply.
>
> Why don't Jet queries support IS NULL or <>''?
>
> Thanks,
>
> Craig

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net