View Single Post
 
Old 03-18-2019, 06:30 PM
ScottyBee ScottyBee is offline Windows 10 Office 2016
Novice
 
Join Date: Mar 2019
Location: Portland, Oregon
Posts: 12
ScottyBee is on a distinguished road
Default Validate textbox fields in VBA Form before Submit

I have a user form I created in VBA that has 8 textboxes for the user to complete. The controls are named txt1, txt2......txt8.

I want to have VBA verify that all fields have been filled in before the code returns the results to the document.

I have a command button in the form that takes the value of each textbox field and inserts it at the designated bookmark in in the document. I successfully added code to the button click event that will display a message box when the user leaves a field empty.

My problem is that I cannot figure out how to break execution of the code which will automatically return focus to the empty field and STAY there. I do have code in the click event to return focus to the empty field but the code continues to run and inserts a null value in the document.

Any ideas are greatly appreciated. BTW, I have done multiple searches on the internet and in here but could not find an answer.

I am using Word 2016 in Windows 10. Thanks
Reply With Quote