Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / April 2004

Tip: Looking for answers? Try searching our database.

Validation rules

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Lee - 29 Apr 2004 03:06 GMT
Please help
how can i only allow user to type leters (like
christopher) only!! not characters (like chris%&her)

   many thanks chris:)
tina - 29 Apr 2004 05:00 GMT
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

> Please help
>  how can i only allow user to type leters (like
> christopher) only!! not characters (like chris%&her)
>
>     many thanks chris:)
John Nurick - 29 Apr 2004 06:51 GMT
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

>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.
tina - 29 Apr 2004 21:25 GMT
cool, both - thanks John!  :)

> Hi Chris,
>
[quoted text clipped - 35 lines]
>
> Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.