Hello!

I manage a workbook with a userform. I have the code in the Save command button (below) which works as intended and is fully functional EXCEPT FOR ONE THING:

I need for the textbox called TXT_Date to reject any entry put into it unless it is an actual date

Users will be users and make mistakes and often i see a date as 01//01/2021 or just as 01/01 or as 01/01/20221.

My end goal is to prevent the userform from saving data unless this criteria is met. If it isn't met then I'd like to inform the user that this field must be corrected.

My question is What to do? and where in the code below to place it?

I feel like i'm so close, but yet so far!!





Private Sub COMM_BUTTON_SAVEINFO_Click()

'This section requires user to fill-in ALL text boxes OR the macro will not run and show the msgbox

If TXT_date.Value = "" Or TXT_AccountName.Value = "" Or TXT_DescriptiveText.Value = "" Or Not Not TXT_CreditAmount.Value = "" Then

MsgBox "You must complete all fields, some boxes are still empty! ", vbCritical
Exit Sub

Else

End If

'-----------------------------------------------------------------------------------------------------------

Dim LBpostingdate As String 'this is the name of the label(s)
LBpostingdate = TXT_date.Text 'this is the name of the label pointing at the text box next to it

Dim LBaccountname As String
LBaccountname = TXT_AccountName.Text

Dim LBdescriptivetext As String
LBdescriptivetext = TXT_DescriptiveText.Text

Dim LBcreditamount As Currency
LBcreditamount = TXT_CreditAmount.Text


Dim wsh As Worksheet
Set wsh = ThisWorkbook.Worksheets("backend")

Set tbl = wsh.ListObjects("table3")
Dim lRow As ListRow
Set lRow = tbl.ListRows.Add

With lRow

.Range(34) = LBpostingdate 'the .range(34) refers to the column number of the table where the information will be placed
.Range(41) = LBaccountname
.Range(56) = LBdescriptivetext
.Range(47) = LBcreditamount

MsgBox "Zero Pay entry yas been recorded successfully"



End With
End Sub