473,395 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

LONG POST: Class Module Property Let Statement "Hangs"

using Access 2003

Pardon the subject line, but I don't have a better word for this
strange
behavior (or behavior I don't understand!!!)

I have a class module named DepreciationFactor. One of the properties
is a follows
(irrelevant code omitted):

..
..
Dim datDisp as Date
Dim datPIS as Date 'This var is set in another property stmt and works
fine
Dim intDispPeriod as Integer
..
..
Property Let DispDate(value as Date)
DispDate = value
intDispPeriod = 1 + (CInt(DatePart("YYYY", value)) -
CInt(DatePart("YYYY", _
datPIS)))
Debug.Print intDispPeriod
End Property

Property Get DispDate() As Date
DispDate = datDisp
End Property
..
..
When I set the DispDate property from client code, I got an Out of
Stack memory
error. So I figured I had a recursive call somewhere. I put
breakpoints in
the class module and ran it again. When the code reached the first
line of the
property let statement for DispDate, it just ran it over and over
again. I can
move the yellow cursor off the DispDate = value line, and the code
will execute
the second line normally. But, when it reaches the Debug line, it
will execute
this line forever, apparently mimicing the behavior of the first line.

Does anyone see anything obviously wrong with the statement? Below is
a copy
of the entire class module for your reference. I'm not a professional
programmer, so be gentle.

Option Compare Database
Option Explicit

'Variables
Dim intLife As Integer 'Class
life
Dim intPeriod As Integer 'Calc
Period
Dim intConvention As Integer
'Convention
Dim dblFactor As Double
'Depreciation factor
Dim dblAccum As Double 'A/D
factor
Dim datPIS As Date 'PIS date
Dim datDisp As Date 'Disposal
date
Dim intYearOfCalculation As Integer 'Based on
period
Dim intDispPeriod As Integer 'Disposal
period
'Properties
Property Let Life(value As Integer)
intLife = value
End Property

Property Get Life() As Integer
Life = intLife
End Property

Property Let Period(value As Integer)
intPeriod = value
End Property

Property Get Period() As Integer
Period = intPeriod
End Property

Property Let Convention(value As Integer)
intConvention = value
End Property

Property Get Convention() As Integer
Convention = intConvention
End Property

Property Get DeprFactor(intOption As Integer) As Double
DeprFactor = FactorPopulator(intOption)
End Property

Property Let PISDate(value As Date)
datPIS = value
If intPeriod <> 0 Then
intYearOfCalculation = CInt(DatePart("YYYY", value)) + (intPeriod
- 1)
End If
End Property

Property Get PISDate() As Date
PISDate = datPIS
End Property

Property Let DispDate(value As Date)
DispDate = value
intDispPeriod = 1 + (CInt(DatePart("YYYY", value)) -
CInt(DatePart("YYYY", datPIS)))
Debug.Print intDispPeriod
End Property

Property Get DispDate() As Date
DispDate = datDisp
End Property
Property Get AccumulatedFactor(intOption As Integer) As Double
AccumulatedFactor = AccumPopulator(intOption)
End Property
'Methods
Private Function AccumPopulator(intDS As Integer) As Double
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim i As Integer
Set db = CurrentDb()
Set rec = db.OpenRecordset(TableSelector(intDS))
Select Case intConvention
Case 1
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", intLife
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Class life invalid."
End If
For i = 1 To intPeriod
If i = intDispPeriod Then
dblAccum = dblAccum + 0.5 * .Fields(i + 1)
Exit For
Else
dblAccum = dblAccum + .Fields(i + 1)
End If
Next
.Close
End With
Case 2
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", CSng(DatePart("m", datPIS))
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Mid-month convention failed."
End If
For i = 1 To intPeriod
If i = intDispPeriod Then
dblAccum = dblAccum + (CDbl((CInt(DatePart("MM",
datDisp)) + 0.5)) / 12) * .Fields(i + 1)
Exit For
Else
dblAccum = dblAccum + .Fields(i + 1)
End If
Next
.Close
End With
Case 3
rec.Close
End Select
AccumPopulator = dblAccum
End Function

Private Function FactorPopulator(intDS As Integer) As Double
Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset(TableSelector(intDS))
Select Case intConvention
Case 1
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", intLife
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Class life invalid."
End If
dblFactor = .Fields(intPeriod + 1)
.Close
End With
Case 2
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", CSng(DatePart("m", datPIS))
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Mid-month convention failed."
End If
dblFactor = .Fields(intPeriod + 1)
.Close
End With
Case 3
rec.Close
End Select
FactorPopulator = dblFactor
End Function

Private Function TableSelector(ByVal intSystem) As String
Dim strPrefix As String
Dim strRate As String
Dim strConv As String
strPrefix = "t_"
Select Case intSystem
Case DeprSystem.ADS
strRate = "100"
Case DeprSystem.GDS
strRate = "200"
Case Else
Err.Raise 10001, "DerpFactor Property of DepreciationFactor",
"Invalid depreciation system."
End Select
Select Case intConvention
Case 1
strConv = "_HY"
Case 2
strConv = "_MM"
Case 3
strConv = "_MQ"
Case Else
Err.Raise 10000, "DeprFactor property of DepreciationFactor",
"Invalid convention"
End Select
TableSelector = strPrefix & strRate & strConv
End Function

Private Sub Class_Initialize()
intLife = 5
intPeriod = 1
intConvention = 1
dblFactor = 0
dblAccum = 0
End Sub
Nov 13 '05 #1
3 2453
rkc

"Johnny M" <jm*******@gmail.com> wrote in message
news:55************************@posting.google.com ...
using Access 2003

Pardon the subject line, but I don't have a better word for this
strange
behavior (or behavior I don't understand!!!)

I have a class module named DepreciationFactor. One of the properties
is a follows
(irrelevant code omitted):

.
.
Dim datDisp as Date
Dim datPIS as Date 'This var is set in another property stmt and works
fine
Dim intDispPeriod as Integer
.
.
Property Let DispDate(value as Date)
DispDate = value
intDispPeriod = 1 + (CInt(DatePart("YYYY", value)) -
CInt(DatePart("YYYY", _
datPIS)))
Debug.Print intDispPeriod
End Property

Property Get DispDate() As Date
DispDate = datDisp
End Property
.
.
When I set the DispDate property from client code, I got an Out of
Stack memory
error. So I figured I had a recursive call somewhere. I put
breakpoints in
the class module and ran it again. When the code reached the first
line of the
property let statement for DispDate, it just ran it over and over
again.


You have a typo in Property Let DispDate and probably have been staring
at it so long that you don't see it.

First line of procedure:
DispDate = value should read datDisp = value.


Nov 13 '05 #2
Please ignore this post. I saw the error right after I sent it in.

My apologies.
Nov 13 '05 #3
> Property Let DispDate(value as Date)
DispDate = value
Yes, that will hang.
That second line is wrong :~)

Dim datDisp as date.

Property Let DispDate(vDate as date)
datDisp = vdate
end

Property Get DispDate() as date
DispDate = datDisp
end

(david)
"Johnny M" <jm*******@gmail.com> wrote in message
news:55************************@posting.google.com ... using Access 2003

Pardon the subject line, but I don't have a better word for this
strange
behavior (or behavior I don't understand!!!)

I have a class module named DepreciationFactor. One of the properties
is a follows
(irrelevant code omitted):

.
.
Dim datDisp as Date
Dim datPIS as Date 'This var is set in another property stmt and works
fine
Dim intDispPeriod as Integer
.
.
Property Let DispDate(value as Date)
DispDate = value
intDispPeriod = 1 + (CInt(DatePart("YYYY", value)) -
CInt(DatePart("YYYY", _
datPIS)))
Debug.Print intDispPeriod
End Property

Property Get DispDate() As Date
DispDate = datDisp
End Property
.
.
When I set the DispDate property from client code, I got an Out of
Stack memory
error. So I figured I had a recursive call somewhere. I put
breakpoints in
the class module and ran it again. When the code reached the first
line of the
property let statement for DispDate, it just ran it over and over
again. I can
move the yellow cursor off the DispDate = value line, and the code
will execute
the second line normally. But, when it reaches the Debug line, it
will execute
this line forever, apparently mimicing the behavior of the first line.

Does anyone see anything obviously wrong with the statement? Below is
a copy
of the entire class module for your reference. I'm not a professional
programmer, so be gentle.

Option Compare Database
Option Explicit

'Variables
Dim intLife As Integer 'Class
life
Dim intPeriod As Integer 'Calc
Period
Dim intConvention As Integer
'Convention
Dim dblFactor As Double
'Depreciation factor
Dim dblAccum As Double 'A/D
factor
Dim datPIS As Date 'PIS date
Dim datDisp As Date 'Disposal
date
Dim intYearOfCalculation As Integer 'Based on
period
Dim intDispPeriod As Integer 'Disposal
period
'Properties
Property Let Life(value As Integer)
intLife = value
End Property

Property Get Life() As Integer
Life = intLife
End Property

Property Let Period(value As Integer)
intPeriod = value
End Property

Property Get Period() As Integer
Period = intPeriod
End Property

Property Let Convention(value As Integer)
intConvention = value
End Property

Property Get Convention() As Integer
Convention = intConvention
End Property

Property Get DeprFactor(intOption As Integer) As Double
DeprFactor = FactorPopulator(intOption)
End Property

Property Let PISDate(value As Date)
datPIS = value
If intPeriod <> 0 Then
intYearOfCalculation = CInt(DatePart("YYYY", value)) + (intPeriod
- 1)
End If
End Property

Property Get PISDate() As Date
PISDate = datPIS
End Property

Property Let DispDate(value As Date)
DispDate = value
intDispPeriod = 1 + (CInt(DatePart("YYYY", value)) -
CInt(DatePart("YYYY", datPIS)))
Debug.Print intDispPeriod
End Property

Property Get DispDate() As Date
DispDate = datDisp
End Property
Property Get AccumulatedFactor(intOption As Integer) As Double
AccumulatedFactor = AccumPopulator(intOption)
End Property
'Methods
Private Function AccumPopulator(intDS As Integer) As Double
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim i As Integer
Set db = CurrentDb()
Set rec = db.OpenRecordset(TableSelector(intDS))
Select Case intConvention
Case 1
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", intLife
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Class life invalid."
End If
For i = 1 To intPeriod
If i = intDispPeriod Then
dblAccum = dblAccum + 0.5 * .Fields(i + 1)
Exit For
Else
dblAccum = dblAccum + .Fields(i + 1)
End If
Next
.Close
End With
Case 2
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", CSng(DatePart("m", datPIS))
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Mid-month convention failed."
End If
For i = 1 To intPeriod
If i = intDispPeriod Then
dblAccum = dblAccum + (CDbl((CInt(DatePart("MM",
datDisp)) + 0.5)) / 12) * .Fields(i + 1)
Exit For
Else
dblAccum = dblAccum + .Fields(i + 1)
End If
Next
.Close
End With
Case 3
rec.Close
End Select
AccumPopulator = dblAccum
End Function

Private Function FactorPopulator(intDS As Integer) As Double
Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset(TableSelector(intDS))
Select Case intConvention
Case 1
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", intLife
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Class life invalid."
End If
dblFactor = .Fields(intPeriod + 1)
.Close
End With
Case 2
With rec
.MoveLast
.MoveFirst
.Index = "fldClassLife"
.Seek "=", CSng(DatePart("m", datPIS))
If .NoMatch Then
Err.Raise 10002, "DeprFactor property of
DepreciationFactor", "Mid-month convention failed."
End If
dblFactor = .Fields(intPeriod + 1)
.Close
End With
Case 3
rec.Close
End Select
FactorPopulator = dblFactor
End Function

Private Function TableSelector(ByVal intSystem) As String
Dim strPrefix As String
Dim strRate As String
Dim strConv As String
strPrefix = "t_"
Select Case intSystem
Case DeprSystem.ADS
strRate = "100"
Case DeprSystem.GDS
strRate = "200"
Case Else
Err.Raise 10001, "DerpFactor Property of DepreciationFactor",
"Invalid depreciation system."
End Select
Select Case intConvention
Case 1
strConv = "_HY"
Case 2
strConv = "_MM"
Case 3
strConv = "_MQ"
Case Else
Err.Raise 10000, "DeprFactor property of DepreciationFactor",
"Invalid convention"
End Select
TableSelector = strPrefix & strRate & strConv
End Function

Private Sub Class_Initialize()
intLife = 5
intPeriod = 1
intConvention = 1
dblFactor = 0
dblAccum = 0
End Sub

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roger Espinosa | last post by:
I'm attempting to install dbxml-1.10 on OS X 10.2.8 (gcc3.x prerelease, Python 2.3.2 built on same), and while everything builds happily, when I try to invoke import dbxml Python just ......
1
by: Vivien Mallet | last post by:
Hello, I use popen2.Popen4 and I experienced problems with it. Let me show you with an example. The following script is called "lines" (it prints lines of 'X'): ---------------------...
22
by: Qopit | last post by:
Hi there, I'm pretty new to Python and am trying to figure out how to get "will this code compile?"-like code checking. To me this is a pretty basic language/environment requirement, especially...
1
by: szudor | last post by:
Hi, When I start db2cc, the program hangs with memory access violation in javaw.exe. Strating with trace option, in java trace file I found the following information: 0SECTION TITLE...
1
by: happyinst | last post by:
I have recently added some code to a web application and now I find it hanging after I do about 2 or 3 postbacks within the application. It hangs after doing different things (I cannot find...
0
by: Phill. W | last post by:
I have a Console application (which will wind up running on a remote host). This has two Threads - the main processor and a second that provides a socket-based way of "talking" to the first. ...
15
by: cedmunds | last post by:
Group: We have an application that is calling a stored proc. The stored proc takes anywhere from 15 to 90 minutes to run. In order to keep the GUI responsive, we are using a BackgroundWorker...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
4
by: dumbkiwi | last post by:
I have written a script that uses the urllib2 module to download web pages for parsing. If there is no network interface, urllib2 hangs for a very long time before it raises an exception. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.