Requiring alpha data entry

D

Dudley

I have a form where if Type1 = 1, the user must enter the first three letters
of the town of birth in Data1. Following previous helpful advice, I have code
which requires the user to enter only alpha characters, but I have found that
this only works to check the first character. Can anyone advise how I can
check all three?

If Forms![Director1 John]![Director1Type1] = "1" And _
(Forms![Director1 John]![Director1Data1] < Chr$("65") Or
Forms![Director1 John]![Director1Data1] = Chr$("91") _
Or Forms![Director1 John]![Director1Data1] = Chr$("92") Or
Forms![Director1 John]![Director1Data1] = Chr$("93") _
Or Forms![Director1 John]![Director1Data1] = Chr$("94") Or
Forms![Director1 John]![Director1Data1] = Chr$("95") _
Or Forms![Director1 John]![Director1Data1] = Chr$("96") Or
Forms![Director1 John]![Director1Data1] > Chr$("122")) Then

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

Thanks for any help.
Dudley
 
N

ntc

I believe the better solution is an alpha only input mask for your form's
text box. This is embedded inherently in a form and if you are not familiar
with it simply search this site or help on input mask....you will find it as
a property for the text box control
 
D

Dudley

Thanks very for your help, but I am not clear how it would work. It did not
seem to work in a function, and if I made a property of the text box I would
presumably not be able to make the data conditional, text or numeric
depending on the type. Can you advise on this please?

Thanks
Dudley

ntc said:
I believe the better solution is an alpha only input mask for your form's
text box. This is embedded inherently in a form and if you are not familiar
with it simply search this site or help on input mask....you will find it as
a property for the text box control


Dudley said:
I have a form where if Type1 = 1, the user must enter the first three letters
of the town of birth in Data1. Following previous helpful advice, I have code
which requires the user to enter only alpha characters, but I have found that
this only works to check the first character. Can anyone advise how I can
check all three?

If Forms![Director1 John]![Director1Type1] = "1" And _
(Forms![Director1 John]![Director1Data1] < Chr$("65") Or
Forms![Director1 John]![Director1Data1] = Chr$("91") _
Or Forms![Director1 John]![Director1Data1] = Chr$("92") Or
Forms![Director1 John]![Director1Data1] = Chr$("93") _
Or Forms![Director1 John]![Director1Data1] = Chr$("94") Or
Forms![Director1 John]![Director1Data1] = Chr$("95") _
Or Forms![Director1 John]![Director1Data1] = Chr$("96") Or
Forms![Director1 John]![Director1Data1] > Chr$("122")) Then

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

Thanks for any help.
Dudley
 
N

ntc

yes, part of the mask capability is to define as alpha only. I believe one
uses the L character. But you should look up "Input Mask" in help or on this
site for further detail.


Dudley said:
Thanks very for your help, but I am not clear how it would work. It did not
seem to work in a function, and if I made a property of the text box I would
presumably not be able to make the data conditional, text or numeric
depending on the type. Can you advise on this please?

Thanks
Dudley

ntc said:
I believe the better solution is an alpha only input mask for your form's
text box. This is embedded inherently in a form and if you are not familiar
with it simply search this site or help on input mask....you will find it as
a property for the text box control


Dudley said:
I have a form where if Type1 = 1, the user must enter the first three letters
of the town of birth in Data1. Following previous helpful advice, I have code
which requires the user to enter only alpha characters, but I have found that
this only works to check the first character. Can anyone advise how I can
check all three?

If Forms![Director1 John]![Director1Type1] = "1" And _
(Forms![Director1 John]![Director1Data1] < Chr$("65") Or
Forms![Director1 John]![Director1Data1] = Chr$("91") _
Or Forms![Director1 John]![Director1Data1] = Chr$("92") Or
Forms![Director1 John]![Director1Data1] = Chr$("93") _
Or Forms![Director1 John]![Director1Data1] = Chr$("94") Or
Forms![Director1 John]![Director1Data1] = Chr$("95") _
Or Forms![Director1 John]![Director1Data1] = Chr$("96") Or
Forms![Director1 John]![Director1Data1] > Chr$("122")) Then

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

Thanks for any 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