Reply to topic  [ 4 posts ] 
Access help 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5151
Location: /dev/tty0
Reply with quote
Hello all,

I've got an Access 2010 db and I'm trying to validate a first name, I'm trying to say that it should only contain letters, an apostrophe, and a hyphen, but I can't find anything that doesn't require you to snoop every key stroke...

Many thanks,

Ben


Wed Feb 01, 2012 2:11 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Regex validator? (You would probably need to do it through VBA)

Something like [a-zA-Z'-]+

I don't think you can snope a key stroke, only a completed field, otherwise every key press would fire validation

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Feb 01, 2012 3:22 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5151
Location: /dev/tty0
Reply with quote
Cheers Finlay :D


Wed Feb 01, 2012 5:46 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
That is a very simple one, you probably need a more comprehensive one though

For instance you wouldn't have a hyphen/apostrophe at the start or end character
It's early, not had enough tea and as a result the way you join them escapes me...

but it would be (in a laypersons notation with partial regex)...
[a-zA-Z] + (0...+ [a-zA-Z'-]+) + [a-zA-Z]
then x'x and x-x are valid but 'xx, xx- and 'x' aren't

The above does cover you for 2 letter names though... not sure if you could validate 1 letter names (or if they exist)

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Thu Feb 02, 2012 8:39 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.