Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

How to verify blank form fields on exit?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
charlie6067 - 05 Oct 2006 18:05 GMT
For example, a protected form has three fields: FName, Initial, and
LName. I need help writing an On Exit macro for the LName field that:

1. Reviews all form fields for blanks.
2. Displays the name of the blank form field(s) so user can correct.

I've tried using bits of code from other postings but can't seem to get
anything to work.

Thanks,
Charlie
charlie6067
Jay Freedman - 05 Oct 2006 19:19 GMT
Instead of one check on exit from the last field, I'd recommend a separate
validation for each field. The reason is that the user could use the mouse
to leave the FName or Initial field without ever going into the LName field,
and then no validation would be done.

You can use the macro in
http://www.word.mvps.org/FAQs/TblsFldsFms/ValidateFFields.htm as a basis.
Change the If statement to

  If Len(Trim(.Result)) = 0 Then

to check for a field that's empty or contains only blank characters.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> For example, a protected form has three fields: FName, Initial, and
> LName. I need help writing an On Exit macro for the LName field that:
[quoted text clipped - 8 lines]
> Charlie
> charlie6067
charlie6067 - 05 Oct 2006 20:55 GMT
Thanks Jay - that worked. Yes, it is better to alert the user right
after the error instead at the end of the form. I appreciated the code.

Charlie
charlie6067

> Instead of one check on exit from the last field, I'd recommend a separate
> validation for each field. The reason is that the user could use the mouse
[quoted text clipped - 28 lines]
> > Charlie
> > charlie6067
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.