A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Validation rules



 
 
Thread Tools Display Modes
  #1  
Old April 29th, 2004, 03:06 AM
Chris Lee
external usenet poster
 
Posts: n/a
Default Validation rules

Please help
how can i only allow user to type leters (like
christopher) only!! not characters (like chris%&her)

many thanks chris
  #2  
Old April 29th, 2004, 05:00 AM
tina
external usenet poster
 
Posts: n/a
Default Validation rules

if you're only allowing a limited number of characters to be entered, for
instance 10, the easiest way i can think of is to add an Input Mask. see the
Input Mask Property topic in Access Help for details.

if you're not limiting the number of characters to be entered, and are doing
the data entry from a form, you can write code that will check the field
data character by character. i've seen examples of such code in recent posts
here in the newsgroups, but not having used the code myself, i don't feel
competent to advise you specifically, sorry.

hth



"Chris Lee" wrote in message
...
Please help
how can i only allow user to type leters (like
christopher) only!! not characters (like chris%&her)

many thanks chris



  #3  
Old April 29th, 2004, 06:51 AM
John Nurick
external usenet poster
 
Posts: n/a
Default Validation rules

Hi Chris,

In Table Design, set a validation rule on the field, like this:

Is Null Or Not Like "*[!A-Za-z]*"

Is Null allows the field to be left empty; remove it if the field must
be filled.

Like "*[!A-Za-z]*" requires at least one character that is not a letter,
and the Not reverses that, thus forbidding any character that is not a
letter.

Users will be able to type anything but the validation rule will be
applied when they move away from the field (including trying to update
the record). If you want also to make it impossible to type incorrect
characters, put something like this in the KeyPress event handler of the
textbox that is displaying the field:

Select Case KeyAscii
Case 8, 9, 13 'Backspace, tab, enter: process these
'Do nothing
Case 65 to 90, 97 to 122 'A-Z, a-z
'Do nothing
Case Else
'supress the keystroke
KeyAscii = 0
End Select

On Wed, 28 Apr 2004 19:06:41 -0700, "Chris Lee"
wrote:

Please help
how can i only allow user to type leters (like
christopher) only!! not characters (like chris%&her)

many thanks chris


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
  #4  
Old April 29th, 2004, 09:25 PM
tina
external usenet poster
 
Posts: n/a
Default Validation rules

cool, both - thanks John!


"John Nurick" wrote in message
...
Hi Chris,

In Table Design, set a validation rule on the field, like this:

Is Null Or Not Like "*[!A-Za-z]*"

Is Null allows the field to be left empty; remove it if the field must
be filled.

Like "*[!A-Za-z]*" requires at least one character that is not a letter,
and the Not reverses that, thus forbidding any character that is not a
letter.

Users will be able to type anything but the validation rule will be
applied when they move away from the field (including trying to update
the record). If you want also to make it impossible to type incorrect
characters, put something like this in the KeyPress event handler of the
textbox that is displaying the field:

Select Case KeyAscii
Case 8, 9, 13 'Backspace, tab, enter: process these
'Do nothing
Case 65 to 90, 97 to 122 'A-Z, a-z
'Do nothing
Case Else
'supress the keystroke
KeyAscii = 0
End Select

On Wed, 28 Apr 2004 19:06:41 -0700, "Chris Lee"
wrote:

Please help
how can i only allow user to type leters (like
christopher) only!! not characters (like chris%&her)

many thanks chris


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.