R
reclusive.monkey
I have created a custom function in Access. I used the Class Module
method as I wanted it to be accessible to Excel. I have this in a class
module in access;
Code:
Option Compare Database
Public Property Get strFinancialYear() As String
myDate = Date - 1
myYear = Year(myDate) - myYearModifier ' Get the year for
yesterday, with our modifier
If (MONTH(myDate)) >= 4 Then ' If we are after april, this year is
first part of FN year
strFinancialYear = myYear & "/" & Right(myYear + 1, 2)
Else
strFinancialYear = myYear - 1 & "/" & Right(myYear, 2)
End If
End Property
Public Function FinancialYear() As String
FinancialYear = Me.strFinancialYear
End Function
This is then called from a module in access;
Function ReportingYear() As String
Dim myReportingYear As New CFinancialYear
ReportingYear = myReportingYear.strFinancialYear
End Function
I then have
ReportingYear()
In a query field to give "2005/06". This works fine. However, when I
try to access this same query from Excel, I get the following error;
[Microsoft][ODBC Microsoft Access Driver] Undefined function
'ReportingYear' in expression
In my references dialog in Excel, I have ticked;
Visual Basic for Applications
Microsoft Excel 10.0 Object Library
Microsoft Forms 10.0 Object Library
Microsoft Access 10.0 Object Library
I cannot find a reference for ODBC anywhere and I have tried ticking as
many references which might seem to be relevant, but I am getting
nowhere. Can anyone see what I am doing wrong as I don't seem to be
able to get anywhere on this I have been trying to get this working for
months now and its becoming very frustrating.
method as I wanted it to be accessible to Excel. I have this in a class
module in access;
Code:
Option Compare Database
Public Property Get strFinancialYear() As String
myDate = Date - 1
myYear = Year(myDate) - myYearModifier ' Get the year for
yesterday, with our modifier
If (MONTH(myDate)) >= 4 Then ' If we are after april, this year is
first part of FN year
strFinancialYear = myYear & "/" & Right(myYear + 1, 2)
Else
strFinancialYear = myYear - 1 & "/" & Right(myYear, 2)
End If
End Property
Public Function FinancialYear() As String
FinancialYear = Me.strFinancialYear
End Function
This is then called from a module in access;
Function ReportingYear() As String
Dim myReportingYear As New CFinancialYear
ReportingYear = myReportingYear.strFinancialYear
End Function
I then have
ReportingYear()
In a query field to give "2005/06". This works fine. However, when I
try to access this same query from Excel, I get the following error;
[Microsoft][ODBC Microsoft Access Driver] Undefined function
'ReportingYear' in expression
In my references dialog in Excel, I have ticked;
Visual Basic for Applications
Microsoft Excel 10.0 Object Library
Microsoft Forms 10.0 Object Library
Microsoft Access 10.0 Object Library
I cannot find a reference for ODBC anywhere and I have tried ticking as
many references which might seem to be relevant, but I am getting
nowhere. Can anyone see what I am doing wrong as I don't seem to be
able to get anywhere on this I have been trying to get this working for
months now and its becoming very frustrating.