A
aehan
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
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