[AccessD] Validation Rule and Hyphen

David Emerson newsgrps at dalyn.co.nz
Tue Feb 10 15:22:04 CST 2015


Found a solution:

Is Null Or Not Like "*[!a-z '-]*"

Not sure why this works and the other format doesn't but there you go.

Thanks for the prompter Lambert.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: Wednesday, 11 February 2015 10:00 a.m.
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Validation Rule and Hyphen

My regular expressions are a bit rusty, but isn't the hyphen a character
used to construct regular expressions? In which case to include it in your
validation you would need to escape the hyphen. Now what's the escape
character?


Lambert  


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David Emerson
Sent: Tuesday, February 10, 2015 2:06 PM
To: AccessD
Subject: [AccessD] Validation Rule and Hyphen

Hi Listers,

I have a field for entering in a last name.  I want to restrict the
characters to letters, spaces, apostrophes, and hyphens.

In the Validation Rule I have:

Is Null Or Not Like "*[!a-z OR "" "" OR ""'"" OR ""-""]*"

This works fine except when I enter a hyphen into the field it is rejected.
I can enter letters, spaces, and apostrophes.  All other characters are
rejected.

Why are hyphens also rejected?

Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand




More information about the AccessD mailing list