Set the forms KeyPreview to true
Add the following code to the textboxes KeyUp event
If KeyCode = 222 Then
If Shift = 1 Then
MsgBox "Please do not use quotations"
Else
MsgBox "Please do not use apostrophes"
End if
Me.Activecontrol = Left(Me.ActiveControl.Text
End If
Main Topics
Browse All Topics





by: RichardCorriePosted on 2002-05-27 at 07:53:51ID: 7037224
use the KeyPress event to cancel the entry thus:
ii as integer)
Private sub txtSurname_KeyPress(KeyAsc
' 39 is single quote, 34 is double quote
if KeyAscii = 39 or KeyAscii = 34 then
KeyAscii = 0 ' null string
end if
End Sub
Beware though, this could lead to some user confusion as they keep hitting the quote key but nothing is output.
If you set the Form KeyPreview property to True you need only create a Form_KeyPress event. This will affect all data entry on the form.
Richard