Hello: I'm trying to activate a command button on an entry form by determining if the year is the year after the current file was created. The purpose is to allow the user to auto-populate data at the beginning of a new golf season. As I am not very familiar with using dates in VBA I have tried a variety of code examples with all giving me errors. My latest attempt is:
All versions tried result in the failure of my entry form to open and this latest version returns an error message "Object doesn't support this property or method" and I feel stupid that I can't see what is causing this.
Thanks in advance for any advice.
Code:
Sub Start_Year()
'Code to determine whether cmdStartYear is enabled
Dim CurrentYear As Date
Dim YrCreated As Date
Dim oWB As Workbook
Set oWB = ActiveWorkbook
CurrentYear = Year(Date)
YrCreated = Format(oWB.DateCreated, "yyyy")
If CurrentYear = YrCreated + 1 Then
cmdStartYear.Visible = True
Else: cmdStartYear.Visible = False
End If
End Sub
All versions tried result in the failure of my entry form to open and this latest version returns an error message "Object doesn't support this property or method" and I feel stupid that I can't see what is causing this.
Thanks in advance for any advice.