Spaces

  • Thread starter Thread starter Pietro
  • Start date Start date
P

Pietro

Hi all,

I've a field in my form called SR where users should copy a serial number
and paste it in this field,I'm worried because some users copy space at the
end or at the beginning of this serial,is there a way to make sure that users
input this serial without spaces?
 
Ini the AfterUpdate event of the text box, put code to remove all of the
spaces:

Private Sub SR_AfterUpdate()

Me.SR = Trim(Replace(Me.SR, " ", ""))

End Sub

Alternatively, you could put code into the BeforeUpdate event to make them
retype it if they haven't done it correctly:

Private Sub SR_BeforeUpdate(Cancel As Integer)

If InStr(Me.SR, " ") > 0 Then
MsgBox "You mistyped SR"
Cancel = True
End If

End Sub
 
Back
Top