Query for Percent Sign ('%') in Field

Using A2003. I tried to query for records that contain a trailing '%'
symbol in a certain field but was unable to get this to work.

Knowing % is a wildcard character I tried substituting the ASCII code
equivalent, but

SELECT * FROM MyTable WHERE MyField LIKE '*' & CHR(37);

returns all records from the table (most of which do not contain the
'%' symbol).

Is there a work-around?
Smartin [ Di, 22 April 2008 00:59 ] [ ID #1947612 ]

Re: Query for Percent Sign ('%') in Field

On Apr 21, 4:59=A0pm, Smartin <smartin... [at] gmail.com> wrote:
> Using A2003. I tried to query for records that contain a trailing '%'
> symbol in a certain field but was unable to get this to work.
>
> Knowing % is a wildcard character I tried substituting the ASCII code
> equivalent, but
>
> SELECT * FROM MyTable WHERE MyField LIKE '*' & CHR(37);
>
> returns all records from the table (most of which do not contain the
> '%' symbol).
>
> Is there a work-around?

this works in access97
SELECT r
FROM Table1
WHERE r Like "*%"
Roger [ Di, 22 April 2008 14:01 ] [ ID #1947634 ]

Re: Query for Percent Sign ('%') in Field

On Apr 22, 8:01=A0am, Roger <lesperan... [at] natpro.com> wrote:
> On Apr 21, 4:59=A0pm, Smartin <smartin... [at] gmail.com> wrote:
>
> > Using A2003. I tried to query for records that contain a trailing '%'
> > symbol in a certain field but was unable to get this to work.
>
> > Knowing % is a wildcard character I tried substituting the ASCII code
> > equivalent, but
>
> > SELECT * FROM MyTable WHERE MyField LIKE '*' & CHR(37);
>
> > returns all records from the table (most of which do not contain the
> > '%' symbol).
>
> > Is there a work-around?
>
> this works in access97
> SELECT r
> FROM Table1
> WHERE r Like "*%"

Thanks for the suggestion (FYI it does not work in A2003 -- the query
returns all rows). I ended up using VBA.
Smartin [ Di, 22 April 2008 15:48 ] [ ID #1947643 ]
Datenbanken » comp.databases.ms-access » Query for Percent Sign ('%') in Field

Vorheriges Thema: tracking changes...this is getting a little too confusing for me
Nächstes Thema: Moving a VBA function to SQL server