Spaces

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?
 
D

Douglas J. Steele

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access Macro Repeat Expression using value of a field in table 0
VB code help 4
Auto Number with Letter Prefix 5
Validation of a field 3
Two fields to one record 1
Control = subForm control 1
dcount 1
Form/ filter for report 2

Top