PC Review


Reply
Thread Tools Rate Thread

Check for leading or trailing spaces

 
 
mjones
Guest
Posts: n/a
 
      25th Oct 2011
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
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      25th Oct 2011
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
 
Reply With Quote
 
mjones
Guest
Posts: n/a
 
      25th Oct 2011
On Oct 25, 12:09*am, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Mon, 24 Oct 2011 19:31:41 -0700 (PDT), mjones
>
>
>
>
>
>
>
>
>
> <mich...@quality-computing.com> 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 alsohttp://www.utteraccess.com


Wonderful! Even better automatic.

John (or anyone), please consider my offer of payment to resolve the
issue in my last post ‘Launching Report from Form Only Shows Report
for First Record’ which turned out to be an issue of two client’s on
the same form. My Invoices and Receipts both have this problem.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:35 AM.