Requiring alpha data entry

  • Thread starter Thread starter Dudley
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top