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 2007

Tip: Looking for answers? Try searching our database.

Template with User Form Required Fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aehan - 25 Oct 2007 17:10 GMT
Hello all

I have created a template which uses a user form to populate sender and
recipient information on a template.

I'm pleased with the result, except for one thing.  I cannot work out how to
keep the user form active if any of the required fields are not filled in.  
What I would like to do is when the OK button is pressed and any of the
required fields are empty, then a message is sent to the user and the form
stays on screen.  I have added this piece of code as part of the
OKbutton_click sub routine:

   If Len(Trim(ComboBox1.text)) <= 0 Or Len(Trim(ComboBox2.text)) <= 0 Or
Len(Trim(DeptAddress.text)) <= 0 _
       Or Len(Trim(EMail.text)) <= 0 Or Len(Trim(Addressee.text)) <= 0 Or
Len(Trim(Address.text)) <= 0 _
           Or Len(Trim(Sal.text)) <= 0 Then
           MsgBox "You must fill in all the required fields"
           UserForm1.Enabled = True

   End If

The message comes up, however the form closes and the letter opens up.  So
miserable failure.  Can anyone help me please?

Thank you
Aehan
Doug Robbins - Word MVP - 26 Oct 2007 05:21 GMT
Add an Exit Sub after the MsgBox command.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello all
>
[quoted text clipped - 24 lines]
> Thank you
> Aehan
aehan - 26 Oct 2007 21:16 GMT
Doh!  Thank you so much.

Aehan

> Add an Exit Sub after the MsgBox command.
>
[quoted text clipped - 26 lines]
> > Thank you
> > Aehan

Rate this thread:






 
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.