How to make userform fields mandatory?

S

Sally

I have designed a userform but I need to ensure one
specific field is filled in before the user hits the
submit button. I don't really care about the other fields
but this one field is definitely needed.

How do I ensure this field is filled in?

Thanks
 
R

Raf

This is how you accomplish it.
1. Open your User form in design mode.
2. Double click on the submit button. This will open a VB
click event.
3. In this event write the following code.

Private sub CmdSubmit_Click()
If UserForm1.Text1.value = "" then
MsgBox"Field ABC is a required field and MUST be
entered before submitting"
exit sub
end if.
end sub.

NOTE: UserForm1 = Name that you gave to the form.
Text1 = Name you gave to the Text box.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top