restrict with wildcard @SQL syntax

G

Gordon Prince

I found this in a post from two years ago:

Restrict [has] a neat little undocumented plus:

strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)

So LIKE can be used in a Restrict clause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "

I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9
 
K

Ken Slovak - [MVP - Outlook]

It was me :)

The "@SQL" has to be used with DASL syntax property tags. That's the mistake
the poster made.

In this case for the filter on BusinessTelephoneNumber you'd use (all on one
line):
"@SQL=" & Chr(34) & "urn:schemas:contacts:blush:fficetelephonenumber" & Chr(34) &
" LIKE = '(901) 503-4774%'"




Michael Bauer said:
What is the guy saying who told you it works?

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 18 Feb 2009 07:17:03 -0800 (PST) schrieb Gordon Prince:
I found this in a post from two years ago:

Restrict [has] a neat little undocumented plus:

strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)

So LIKE can be used in a Restrict clause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "

I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9
 
G

Gordon Prince

It was me :)

The "@SQL" has to be used with DASL syntax property tags. That's the mistake
the poster made.

In this case for the filter on BusinessTelephoneNumber you'd use (all on one
line):
"@SQL=" & Chr(34) & "urn:schemas:contacts:blush:fficetelephonenumber" & Chr(34) &
" LIKE = '(901) 503-4774%'"







What is the guy saying who told you it works?
 : Outlook Categories? Category Manager Is Your Tool
 : VBOffice Reporter for Data Analysis & Reporting
 : <http://www.vboffice.net/product.html?pub=6&lang=en>
Am Wed, 18 Feb 2009 07:17:03 -0800 (PST) schrieb Gordon Prince:
I found this in a post from two years ago:
Restrict[has] a neat little undocumented plus:
strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)
So LIKE can be used in aRestrictclause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "
I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9- Hide quoted text -

- Show quoted text -

Worked without the "=" after the LIKE.
"@SQL=" & Chr(34) & "urn:schemas:contacts:blush:fficetelephonenumber" & Chr
(34) &
" LIKE '(901) 503-4774%'"

Thanks.
 
G

Gordon Prince

It was me :)

The "@SQL" has to be used with DASL syntax property tags. That's the mistake
the poster made.

In this case for the filter on BusinessTelephoneNumber you'd use (all on one
line):
"@SQL=" & Chr(34) & "urn:schemas:contacts:blush:fficetelephonenumber" & Chr(34) &
" LIKE = '(901) 503-4774%'"







What is the guy saying who told you it works?
 : Outlook Categories? Category Manager Is Your Tool
 : VBOffice Reporter for Data Analysis & Reporting
 : <http://www.vboffice.net/product.html?pub=6&lang=en>
Am Wed, 18 Feb 2009 07:17:03 -0800 (PST) schrieb Gordon Prince:
I found this in a post from two years ago:
Restrict[has] a neat little undocumented plus:
strRestrict = "@SQL=" ' then add the filter to that. no spaces.
oItems.Restrict(strRestrict)
So LIKE can be used in aRestrictclause :)
--------------------------------------------------------------
I can't get these phrases to work. Anyone have an idea what would work
here?
strRestrict = "@SQL=[BusinessTelephoneNumber] like '(901) 503-4774%' "
I'm getting an error message:
Cannot parse condition. Error at
"@SQL=[BusinessTelephoneNumber] like '(9- Hide quoted text -

- Show quoted text -

Here's my final code with some "OR" clauses included:
strPhoneCriteria = "@SQL=" & Chr(34) &
"urn:schemas:contacts:blush:fficetelephonenumber" & Chr(34) & " LIKE '" &
strPhone & "%'" & _
" OR " & Chr(34) &
"urn:schemas:contacts:homePhone" & Chr(34) & " LIKE '" & strPhone &
"%'" & _
" OR " & Chr(34) &
"urn:schemas:contacts:mobile" & Chr(34) & " LIKE '" & strPhone & "%'"
& _
" OR " & Chr(34) &
"urn:schemas:contacts:blush:therTelephone" & Chr(34) & " LIKE '" & strPhone
& "%'"
 
K

Ken Slovak - [MVP - Outlook]

Sorry, that was a typo putting in that extra "=" character.




<snip>
Worked without the "=" after the LIKE.
"@SQL=" & Chr(34) & "urn:schemas:contacts:blush:fficetelephonenumber" & Chr
(34) &
" LIKE '(901) 503-4774%'"

Thanks.
 
Joined
Aug 6, 2010
Messages
5
Reaction score
0
How can I use a wildcard in the DASL syntax of the Restrict Method

strRestrict = "@SQL=urn:schemas:httpmail:sender LIKE '*Smith*'"
Set myItems = myMail.Restrict(strRestrict)

The * causes the code not to work.
 

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