On Mon, 24 Oct 2011 19:31:41 -0700 (PDT), mjones
<(E-Mail Removed)> wrote:
>Hi All,
>
>My staff keeps copying and pasting text into form fields from emails
>and such with trailing and leading spaces, e.g. on email addresses.
>Obviously, this is junk data.
>
>Is there a way to on exit or the like, check for leading and/or
>trailing spaces and give an error until they fix it?
>
>Something like -
>
>If Me!EmailP "STARTS OR ENDS WITH A SPACE" Then
> MsgBox "Email cannot start or end with a space'"
> Cancel = False
>End If
>
>Hum, probably not that simple, but one can hope.
>
>Thanks a bunch,
>
>Michele
Access automatically trims trailing blanks.
What I'd suggest is that you simply trim the input silently, without annoying
your users with a message; you can put code into the textbox's AfterUpdate
event (oddly, that is the AFTER update event, not Before):
Private Sub txtEmail_AfterUpdate()
Me!txtEmail = Trim(Me!txtEmail)
End Sub
This will trim both ends.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also
http://www.utteraccess.com