LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reference Class Module in Access from Excel

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.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reference a Class Module located in an add-in or another workbook? keithb Excel Programming 1 September 10th 05 01:40 AM
Excel ActiveX causes lost Class Module reference Jason Webley Excel Programming 2 May 30th 05 11:43 AM
How can I name the Module or class after I insert it into the Excel new.microsoft.com Excel Programming 2 January 17th 04 04:18 AM
Exposing Class Module from VBA Excel 97 SR-2 hakim Excel Programming 3 November 5th 03 05:54 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"