How to restrict certain characters in a text field?

  • Thread starter Thread starter Oisin
  • Start date Start date
O

Oisin

I want to restrict the entry of certain characters in a text field in Access
97. I know I can create a validation rule for the field but I don't see how
I can build an expression to disallow certain characters.
For example, I want to disallow commas and doubles quotes from the text
entered in a text field.

Your help is much appreciated,
Oisin.
 
Using the BeforeUpdate event, which can cancel the update, you can write
something like (aircode):

Sub txtBoxName_BeforeUpdate(Cancel As Integer)
If Instr(Me.txtBoxName,",")>1 Then
MsgBox "Mama don't low no commas in here"
Cancel = True
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Arvin Meyer said:
Using the BeforeUpdate event, which can cancel the update, you can
write something like (aircode):

Sub txtBoxName_BeforeUpdate(Cancel As Integer)
If Instr(Me.txtBoxName,",")>1 Then
MsgBox "Mama don't low no commas in here"
Cancel = True
End If
End Sub

It seems Mama 'lows one comma! :-)
 
Lynn Trapp said:
Thus, you should have said:

Mama don't 'low no commas typed in here
Mama don't 'low no commas typed in here
We don't care what Mama don't 'low
Gonna type one comma any how
Mama just 'lowed one comma typed in here

LOL
 
Back
Top