PC Review


Reply
Thread Tools Rate Thread

ADO Recordset Filter for alpha

 
 
dsimcox
Guest
Posts: n/a
 
      20th Mar 2008
I'm using VBA and ADO to retrieve a recordset from SQL Server - then
filtering the recordset to get the target records.

Some of my records have a numeric prefix - and some have an alpha prefix.

In my source query I use "partNo LIKE '[A-Z]%'" to extract the recordset.
But when I try to use the same logic in the recordset filter, it fails to
find the records. I've tested the result by filtering for the exact prefix
("partNo LIKE 'WW6%'") and it works, so I know the records are there. But I
need a more general way of defining the filter

Here's the filter criteria that fails. It returns NO records - when records
like WW65-ABCD exist. Can someone point me to another solution?

rsAddAllRaw.Filter = "partNo LIKE '[A-Z]%'"
 
Reply With Quote
 
 
 
 
GysdeJongh
Guest
Posts: n/a
 
      21st Mar 2008
"dsimcox" <(E-Mail Removed)> wrote in message
news:3C99427E-AD30-43B2-86F9-(E-Mail Removed)...
> I'm using VBA and ADO to retrieve a recordset from SQL Server - then
> filtering the recordset to get the target records.
>
> Some of my records have a numeric prefix - and some have an alpha prefix.
>
> In my source query I use "partNo LIKE '[A-Z]%'" to extract the recordset.
> But when I try to use the same logic in the recordset filter, it fails to
> find the records. I've tested the result by filtering for the exact
> prefix
> ("partNo LIKE 'WW6%'") and it works, so I know the records are there. But
> I
> need a more general way of defining the filter
>
> Here's the filter criteria that fails. It returns NO records - when
> records
> like WW65-ABCD exist. Can someone point me to another solution?
>
> rsAddAllRaw.Filter = "partNo LIKE '[A-Z]%'"


Hi dsimcox,
just maybe if you retrieve the set from the SQL server T-SQL is used in a
stored procedure (?) Then the % is a wildcard character.If you use VBA and
ADO then * is the wild card character.

Try rsAddAllRaw.Filter = "partNo LIKE '[A-Z]*'"
Just for fun
hth
Gys


 
Reply With Quote
 
dsimcox
Guest
Posts: n/a
 
      21st Mar 2008
Thanks for the reply Gys . . .

Your suggestion did not work for me, I'm sorry to say. I have other filters
on this recordset that also use the % wildcard that are functioning properly
- so I think this is the correct wildcard to use in my VBA code.

I was able to work around this problem by creating a specific query for this
case - avoiding the need to filter the recordset - but I'd sure like to know
how to filter for a string that begins with alpha characters.


> Hi dsimcox,
> just maybe if you retrieve the set from the SQL server T-SQL is used in a
> stored procedure (?) Then the % is a wildcard character.If you use VBA and
> ADO then * is the wild card character.
>
> Try rsAddAllRaw.Filter = "partNo LIKE '[A-Z]*'"
> Just for fun
> hth
> Gys
>
>
>

 
Reply With Quote
 
Dick Kusleika
Guest
Posts: n/a
 
      21st Mar 2008
On Thu, 20 Mar 2008 14:21:02 -0700, dsimcox
<(E-Mail Removed)> wrote:

>I'm using VBA and ADO to retrieve a recordset from SQL Server - then
>filtering the recordset to get the target records.
>
>Some of my records have a numeric prefix - and some have an alpha prefix.
>
>In my source query I use "partNo LIKE '[A-Z]%'" to extract the recordset.
>But when I try to use the same logic in the recordset filter, it fails to
>find the records. I've tested the result by filtering for the exact prefix
>("partNo LIKE 'WW6%'") and it works, so I know the records are there. But I
>need a more general way of defining the filter
>
>Here's the filter criteria that fails. It returns NO records - when records
>like WW65-ABCD exist. Can someone point me to another solution?
>
>rsAddAllRaw.Filter = "partNo LIKE '[A-Z]%'"


I don't know why this doesn't work. It must be a quirk of Filter, although
that doesn't seem right to me. Here's another workaround if you're
interested:

sSQL = "SELECT DocID, DocTitle, left(DocVersion,1) AS Expr1 FROM
tblDocuments"

Set rs = cn.Execute(sSQL)

rs.Filter = "Expr1 > '9'"

I pull the left-most character from DocVersion and get only those greater
than the string '9', which effectively gets those that start with a letter.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
 
Reply With Quote
 
GysdeJongh
Guest
Posts: n/a
 
      23rd Mar 2008
"dsimcox" <(E-Mail Removed)> wrote in message
news:81A3BFBD-A46E-44DA-BFE7-(E-Mail Removed)...
> Thanks for the reply Gys . . .
>
> Your suggestion did not work for me, I'm sorry to say. I have other
> filters
> on this recordset that also use the % wildcard that are functioning
> properly
> - so I think this is the correct wildcard to use in my VBA code.
>
> I was able to work around this problem by creating a specific query for
> this
> case - avoiding the need to filter the recordset - but I'd sure like to
> know
> how to filter for a string that begins with alpha characters.


Hi dsimcox,
what does your workaround looklike ?

For me the filter on the record set only works with a client side- and
static cursor.Have you tried that combination of parameters ?
Gys


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange problem with asp:Textbox and CSS filter:alpha sjickells@gmail.com Microsoft ASP .NET 0 21st Jun 2007 03:44 PM
BUG: ClearType Tuner and style filter: alpha(opacity=0) not compatible TJO Windows XP Internet Explorer 1 10th Feb 2006 07:50 PM
RE: DAO Recordset Filter =?Utf-8?B?T2Zlcg==?= Microsoft Access VBA Modules 0 2nd Nov 2005 05:25 PM
Alpha Filter Buttons =?Utf-8?B?Q3lyaWwgdGhlIFNxdWlycmVs?= Microsoft Access 1 1st Dec 2004 11:42 AM
Filter Recordset- Arlan Microsoft Access VBA Modules 3 21st Oct 2004 12:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:36 AM.