New Member
February 20, 2021
Hi,
This code was working fine previously but, now the Format statement generates a compiler error "Compile error: Can't find project or library". Has this been changed in vba? FYI.This bit of code is called from a UserForm TextBox that requests a date, other information I use Excel 2019 and Windows 11.
Can anybody please assist as to why this code generate an error, I use the Day, Month and Year date format.
Private Sub tb_Date_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim TNumb, MyLastRow, MyN, NextTN As Long
Dim MyDate As Date
Dim Response As VbMsgBoxResult
Dim Ed As String, Fd As String
Dim Admin As Worksheet
Set Admin = ThisWorkbook.Worksheets("Admin")
Ed = " The entered Date: "
Fd = " is in the future! Do you want to use that Date?"
On Error GoTo ErrorHandler
MyDate = Me.tb_Date
On Error GoTo 0
'******* Check if the entered date is a future date ***************
If MyDate > Now() Then
Response = MsgBox("Today's date is: " & Format(Now(), "dd mmm yyyy") & Ed & Format(MyDate, "dd mmm yyyy") & Fd, vbYesNo + vbDefaultButton2 + vbQuestion, "Future Date Entered")
If Response = vbNo Then
Me.tb_Date = ""
Exit Sub
End If
End If
'*******************************************************************
Me.tb_Date = Format(MyDate, "dd mmm yyyy")
Me.tbTransNum.Visible = True
Me.lblTransNo.Visible = True
'********** Set the next Transaction Number ************
TNumb = Admin.Cells(2, 2)
NextTN = TNumb + 1
Admin.Cells(2, 2) = NextTN
'*******************************************************
Me.tbTransNum = "TN" & NextTN
Me.lblTransFor.Visible = True
Me.OBtn_Tre.Visible = True
Me.OBut_Jill.Visible = True
Me.BtnSave.Visible = True
Exit Sub
ErrorHandler:
If Err = 13 Then
MsgBox "Date entered is not Valid! Please enter a valid date.", vbOKOnly
Me.tb_Date = ""
Exit Sub
End If
End Su
1 Guest(s)