reclusivemonkey
Registered User.
- Local time
- Today, 05:41
- Joined
- Oct 5, 2004
- Messages
- 749
I am trying (unsuccessfully) to get Class Modules clear in my feeble brain. I've got plenty text books, I've read up on support.microsoft.com, googled and read all the forums I can find. The most useful thing I've found so far is the post here;
http://www.access-programmers.co.uk/forums/showthread.php?t=93726
Following this example, I've actually got *something* working, rather than the errors I have been getting for the past few weeks. My intention here is to set up a function which calculates, from the current date, the reporting month (i.e. the month of the date yesterday), current financial year, etc. so that I can pull data automatically from my Access database to Excel. This works fine when I reference variables from forms/etc. But ideally I want it to be "smarter"; I have got this far;
This resides in CReporting, a class module in the Access Database. When I call a sub from a regular module in the db like this;
All I get is 00:00:00, when I am expecting today's date. I'm not too bad with VBA in general, its vastly decreased my working time in many areas, but the whole class modules are just one layer of abstraction too far for my feeble brain. If I can get one value returned, I'll be off, but I am totally stuck here. I've started reading up on Property Get/Let/Set, but that only confused me more...
http://www.access-programmers.co.uk/forums/showthread.php?t=93726
Following this example, I've actually got *something* working, rather than the errors I have been getting for the past few weeks. My intention here is to set up a function which calculates, from the current date, the reporting month (i.e. the month of the date yesterday), current financial year, etc. so that I can pull data automatically from my Access database to Excel. This works fine when I reference variables from forms/etc. But ideally I want it to be "smarter"; I have got this far;
Code:
Option Compare Database
Private dteToday As Date
Private intMonth As Integer
Private strFYear As String
Private Sub SetDate()
dteToday = Date
End Sub
Public Function Reporting() As Date
Reporting = dteToday
End Function
This resides in CReporting, a class module in the Access Database. When I call a sub from a regular module in the db like this;
Code:
Sub Test()
Dim TestDate As CReporting
Set TestDate = New CReporting
MsgBox TestDate.Reporting
End Sub
All I get is 00:00:00, when I am expecting today's date. I'm not too bad with VBA in general, its vastly decreased my working time in many areas, but the whole class modules are just one layer of abstraction too far for my feeble brain. If I can get one value returned, I'll be off, but I am totally stuck here. I've started reading up on Property Get/Let/Set, but that only confused me more...