Chi Is Current
asked on
Validation Rule: Limit entry to alphanumeric characters plus: './+-(space)'
Hello ~
I'm writing a validation rule to limit acceptable characters to ONLY: Like "[0-9A-Z./+ -]"
That's:
0-9
A-Z
.
/
+
(space)
-
Using: Like "[0-9A-Z./+ -]" for the rule invalidates everything. How can I write the rule to allow only these characters?
Many THanks, Jacob
I'm writing a validation rule to limit acceptable characters to ONLY: Like "[0-9A-Z./+ -]"
That's:
0-9
A-Z
.
/
+
(space)
-
Using: Like "[0-9A-Z./+ -]" for the rule invalidates everything. How can I write the rule to allow only these characters?
Many THanks, Jacob
ASKER
matthewspatrick ~
Thank you for your reply. I actually have a rule I'm using in the BeforeUpdate event for the field's text box that works pretty well:
'Does the VIN conform to code39?
sPattern = "*[!0-9A-Z./+$% -]*"
If (Me.VendorItemNumber) Like sPattern Then 'NOT WITHIN CODE39 SYMBOLOGY
MsgBox "You have entered an INVALID CHARACTER in this field." & vbCrLf & "Vendor Item Numbers must conform to Code39 symbology.", vbCritical, "Invalid Character!"
Cancel = True
Exit Sub
End If
I'm looking for a way to write a validation rule for the table field, in case someone attempts to defeat the form's test.
???
Thank you for your reply. I actually have a rule I'm using in the BeforeUpdate event for the field's text box that works pretty well:
'Does the VIN conform to code39?
sPattern = "*[!0-9A-Z./+$% -]*"
If (Me.VendorItemNumber) Like sPattern Then 'NOT WITHIN CODE39 SYMBOLOGY
MsgBox "You have entered an INVALID CHARACTER in this field." & vbCrLf & "Vendor Item Numbers must conform to Code39 symbology.", vbCritical, "Invalid Character!"
Cancel = True
Exit Sub
End If
I'm looking for a way to write a validation rule for the table field, in case someone attempts to defeat the form's test.
???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I've had the pleasure of meeting Allen, he is a giant in our field :)
I could not remember that ! was the "not" operator for Access's "light" version of regular expressions used
for the Like operator. Oh well :)
I could not remember that ! was the "not" operator for Access's "light" version of regular expressions used
for the Like operator. Oh well :)
Update event in your form to test.
It would go something like this:
If RegExpFind(Me!NameOfTextbo
MsgBox "Invalid character in textbox", vbCritical, "No soup for you!"
Cancel = True
Me.NameOfTextbox.SetFocus
End If
Open in new window