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