(Solved) – Cannot validate activex textboxes in form (not a userform) just a form in the Word document itself

(solved)-–-cannot-validate-activex-textboxes-in-form-(not-a-userform)-just-a-form-in-the-word-document-itself

I’ve looked all over for the solution to this, finally figured I would just ask.

I have a form I’ve created in Word. It is not a formal “userform1” type form as in a VB project. It is written all in the Word document itself.

I am going to have a lead person email my this report every evening. I have been able to successfully have the user click the submit button and email the form (MS Word (NighlyReport.DOCM)).

In the final stages now, I am “trying with no success” to validate all of my textboxes with no luck.

I want to make each textbox required and if the user does not enter a value, I would like the “setFocus” to return the user back to the textbox. Since I am not using an official “userform” I do not seem to have this method available to me – to return the user back to the form. I have tried
_Change
_GotFocus
_LostFocus
_KeyPress
_MouseDown

All of these work fine as long as I am inside the textbox. None of them sends the user back to it.

Does anybody know a way to do this. I wanted a straightforward nice looking form to fill out and attach to outlook (which I’ve done). Just need to validate the textboxes. I would be willing to validate all of them with a commandbutton as well, but still cannot get the focus back to the textbox that was not filled out by the user.

For the sake of simplicity, I am posting just two textboxes here and my basic validation that is not working. To be clear, I am not using the userform grid, maybe that makes all of this impossible to do.

Thanks ahead:

enter code here

Private Sub txt1_Change()

If txt1.Value = “” Then
MsgBox “need your input”
Else
Exit Sub
End If
End Sub

Private Sub txt2_Change()

If txt2.Value = “” Then
MsgBox “need your input”
Else
Exit Sub
End If
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *