How would I incorporate "on error" into my code so that if a user enters something into a textbox that is not a date formatted to MM/DD/YYYY or left blank it will not exit out of my userform. Other solutions are appreciated as well!
The code:
Private Sub CommandButton1_Click()
Dim s As String
s = Me.TextBoxx25.Text
If s = "" Then
ElseIf DateDiff("d", Me.TextBoxx25.Text, "11/12/2020") > 0 Then
Doc1.Bookmarks("bmrow1").Range.Cells.Delete
Doc2.Variables("TextBoxx25").Value = Me.TextBoxx25.Text
Doc2.Variables("TextBoxx1").Value = Me.TextBoxx1.Text
Doc2.Variables("TextBoxx7").Value = Me.TextBoxx7.Text
Doc2.Variables("TextBoxx13").Value = Me.TextBoxx13.Text
Doc2.Variables("TextBoxx19").Value = Me.TextBoxx19.Text
Doc2.Variables("TextBoxx31").Value = Me.TextBoxx31.Text
Else
Doc1.Variables("TextBoxx25").Value = Me.TextBoxx25.Text
Doc1.Variables("TextBoxx1").Value = Me.TextBoxx1.Text
Doc1.Variables("TextBoxx7").Value = Me.TextBoxx7.Text
Doc1.Variables("TextBoxx13").Value = Me.TextBoxx13.Text
Doc1.Variables("TextBoxx19").Value = Me.TextBoxx19.Text
Doc1.Variables("TextBoxx31").Value = Me.TextBoxx31.Text
Doc2.Bookmarks("bmrow1").Range.Cells.Delete
End If
It would have to display a msgbox that says please format as (MM/DD/YYYY)