Forum

Notifications
Clear all

Format Dates Etc

3 Posts
2 Users
0 Reactions
68 Views
(@ivandam)
Posts: 2
New Member
Topic starter
 

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

 
Posted : 09/07/2022 12:13 am
(@debaser)
Posts: 837
Member Moderator
 

You have a missing reference. With that project active in the VBE, click Tools - References and look for one (or more) of the checked references that has 'MISSING:' at the start of its name.

 
Posted : 09/07/2022 3:55 am
(@ivandam)
Posts: 2
New Member
Topic starter
 

Thank you Velouria That has fixed the problem.

 
Posted : 10/07/2022 6:19 pm
Share: