D
Dudley
I have forms where the user is required to enter data as for example, if type
=1, then data = the first three letters of the town of birth, and I have put
in error checking to only allow letters as
If Forms![Director1 John]![Director1Type1] = "7" 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") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) > Chr$("122") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) > Chr$("122")) Then
fnErrorCheck = False
MsgBox "Invalid mother's maiden name"
Exit Function
Else
fnErrorCheck = True
End If
This worked fine until a user put in the first letter as Z, when he got the
error message. I have found that the problem does not occur when Z is the
second or third letter, so I have tried code:
If Forms![Director1 John]![Director1Type1] = "1" And _
(Mid(Forms![Director1 John]![Director1Data1], 1, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) > Chr$("122") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) > Chr$("122") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) > Chr$("122")) Then
fnErrorCheck = False
MsgBox "Invalid town of birth"
Exit Function
Else
fnErrorCheck = True
End If
This always works including for first letter Z. Can anyone advise what the
problem is with the first code, and is there any way round me going through
all the many cases where I have used the first code and revising it?
Thanks for any help.
Dudley
=1, then data = the first three letters of the town of birth, and I have put
in error checking to only allow letters as
If Forms![Director1 John]![Director1Type1] = "7" 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") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) > Chr$("122") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) > Chr$("122")) Then
fnErrorCheck = False
MsgBox "Invalid mother's maiden name"
Exit Function
Else
fnErrorCheck = True
End If
This worked fine until a user put in the first letter as Z, when he got the
error message. I have found that the problem does not occur when Z is the
second or third letter, so I have tried code:
If Forms![Director1 John]![Director1Type1] = "1" And _
(Mid(Forms![Director1 John]![Director1Data1], 1, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 1, 1) > Chr$("122") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 2, 1) > Chr$("122") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) < Chr$("65") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("91") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("92") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("93") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("94") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("95") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) = Chr$("96") _
Or Mid(Forms![Director1 John]![Director1Data1], 3, 1) > Chr$("122")) Then
fnErrorCheck = False
MsgBox "Invalid town of birth"
Exit Function
Else
fnErrorCheck = True
End If
This always works including for first letter Z. Can anyone advise what the
problem is with the first code, and is there any way round me going through
all the many cases where I have used the first code and revising it?
Thanks for any help.
Dudley