Requiring alpha data entry

D

Dudley

I want to give an error message when a user does not enter alpha characters
only, but my code does not work.

If Type1 = 1, then the user should enter the first three letters of the town
of birth in Data1.

If Forms![Director1 John]![Director1Type1] = "1" And _
(Forms![Director1 John]![Director1Data1] < Asc("64")) And
(Forms![Director1 John]![Director1Data1] > Asc("91")) _
Or (Forms![Director1 John]![Director1Data1] < Asc("96")) And
(Forms![Director1 John]![Director1Data1] > Asc("123")) Then

fnErrorCheck = False
MsgBox "Invalid town of birth"
Exit Function
Else
fnErrorCheck = True
End If


Many thanks if anyone can help.

Dudley
 
D

Dorian

You need CHR$(number) not ASC("number")
Towns can also contain hyphens and apostrophes I believe.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
D

Dudley

Thanks very much for your help. I take your point about hyphens etc, but I
think it is simpler to limit users to alpha characters.

Dudley

Dorian said:
You need CHR$(number) not ASC("number")
Towns can also contain hyphens and apostrophes I believe.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


Dudley said:
I want to give an error message when a user does not enter alpha characters
only, but my code does not work.

If Type1 = 1, then the user should enter the first three letters of the town
of birth in Data1.

If Forms![Director1 John]![Director1Type1] = "1" And _
(Forms![Director1 John]![Director1Data1] < Asc("64")) And
(Forms![Director1 John]![Director1Data1] > Asc("91")) _
Or (Forms![Director1 John]![Director1Data1] < Asc("96")) And
(Forms![Director1 John]![Director1Data1] > Asc("123")) Then

fnErrorCheck = False
MsgBox "Invalid town of birth"
Exit Function
Else
fnErrorCheck = True
End If


Many thanks if anyone can help.

Dudley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top