Case Statement - Error handling

S

Sue

Hi. I've created an Userform. I have a ListBox. A selection from the
ListBox will cause a BuildingBlockEntry to be inserted at a Bookmark.
When the Submit button is clicked, if a selection has not been made
from the ListBox, I have the Case Else show a MessageBox, Unload the
Userform, then reshow a fresh UserForm.

**************************************************
Case Else

MsgBox "You did not select a company location."

Unload Me

UserForm1.Show
****************************************************

The problem is my Userform also contains many TextBoxes and some
CheckBoxes, all which map to Bookmarks in the document. Anything
entered in the Userform is inserted at the Bookmarks, every time the
Submit button is clicked. How do I prevent that? I could use
ActiveDocument.Close, do not SaveChanges -- but I'd have to reopen the
template and I don't have a static path to code.

This was suggested to me and it doesn't work. I think the idea is if a
selection in ListBox1 wasn't made, this forces it back to ListBox1
without populating the document with values from the TextBoxes and
CheckBoxes - which is a good idea.

***********************************
Case Else
MsgBox "You did not select a company location."
Me.ListBox1.SetFocus

***********************************

All ideas appreciated! I'm a slightly above beginner level in VBA.
Thanks in advance.

Sue Hunter
 

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