Kamis, 03 Mei 2012

RE: [MS_AccessPros] catalogue the properties and their values for a custom class instance

 

Glenn-

I guess I'm not understanding why you have two instances of the class. When you
instantiate a copy, it should be a "clean slate" with regard to properties of
the class. If you ask the new copy to do something with a filter applied, then
you should get that result – unless there's a bug in your class module.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

---------------------------------

From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Glenn Lloyd
Sent: Thursday, May 03, 2012 3:57 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] catalogue the properties and their values for a
custom class instance

 
That's true at that point John but only so that I can duplicate the data
that the instances have in common. opPtrTxnData is a pointer to the original
instance. MilestoneTxns is the second instance and I start using it at Line
160.

Glenn

'copy required data to new object

40 With oPtrTxnData

'save query to be used as the base for each milestone

50 MilestoneTxns.SQLBase = .SQL

'client/member/portfolio/fund selection data should be in .sql

'copy them here for reference

60 MilestoneTxns.ClientID = .ClientID

70 MilestoneTxns.ClientMemberID = .ClientMemberID

80 MilestoneTxns.PortfolioID = .PortfolioID

90 MilestoneTxns.FundID = .FundID

100 MilestoneTxns.ValuationDate = .ValuationDate

110 MilestoneTxns.MarketValue = .MarketValue

120 MilestoneTxns.DateRange.dateTo = .DateRange.dateTo

130 MilestoneTxns.ValuationHistory.DateCurrent =
.ValuationHistory.DateCurrent

'may not be required

140 MilestoneTxns.ValuationHistory.calcMilestones

150 End With

'calculate ror for streams with inception prior to one year milestone

160 With MilestoneTxns

#If Diagnostic Then

170 .InitResultsLogging "1 Year Milestone"

#End If

From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of John Viescas
Sent: May-03-12 8:20 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] catalogue the properties and their values for a
custom class instance

Glenn-

I see you create a new instance of the Class, but then you use the class
passed
to you (oPtrTxnData):

30 Set MilestoneTxns = New clsTxnDataExtended

'copy required data to new object

40 With oPtrTxnData

'save query to be used as the base for each milestone

50 MilestoneTxns.SQLBase = .SQL

What is oPtrTxnData pointing to? If it's the "original" instance of the
class,
perhaps that's why it's not changing when you call it the second time.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----------------------------

From: MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com>
[mailto:MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Glenn
Lloyd
Sent: Thursday, May 03, 2012 1:36 PM
To: MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com>
Subject: RE: [MS_AccessPros] catalogue the properties and their values for a
custom class instance

Hi John,

Some of the code in the class module is proprietary so I can't post the
class. But I wonder if the specific code within the class module would make
a difference since I want to work generically. I am hoping to avoid having
to manually create statements to access each property.

The form involved has an object property of type clsTxnDataExtended. Then I
use a procedure to create a second instance:

Public Sub CalculateMilestoneRoR(oPtrTxnData As clsTxnDataExtended)

' Procedure: CalculateMilestoneRoR

' DateTime: 24/04/2012 10:26:15 AM

' Author: Glenn Lloyd

' Description: Calculate Milestone Rates of Return

'

' argument oPtrTxnData is not strictly required - it is used

' here to allow for possible portability of the function. As

' a form procedure the form's variable which has already

' been instantiated should be passed to the procedure

'

'--

Const cstrProcedure = "CalculateMilestoneRoR"

'we need a reference to currentdb

Dim db As DAO.Database

Dim rst As DAO.Recordset

'use a local instance of Transaction data

Dim MilestoneTxns As clsTxnDataExtended

Dim strSQLMilestone As String

Dim strSQLUnion As String

Dim strSQL As String

Dim TransactionCount As Long

10 On Error GoTo HandleError

20 Set db = CurrentDb

30 Set MilestoneTxns = New clsTxnDataExtended

'copy required data to new object

40 With oPtrTxnData

'save query to be used as the base for each milestone

50 MilestoneTxns.SQLBase = .SQL

And so on.

Glenn

From: MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com>
[mailto:MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of John
Viescas
Sent: May-03-12 7:02 AM
To: MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com>
Subject: RE: [MS_AccessPros] catalogue the properties and their values for a
custom class instance

Glenn-

Can you post the code for the Class module and the code you're using to
invoke
it?

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

----------------------------------

From: MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com>
<mailto:MS_Access_Professionals%40yahoogroups.com>
[mailto:MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com>
<mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Glenn
Lloyd
Sent: Thursday, May 03, 2012 12:31 PM
To: MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com>
<mailto:MS_Access_Professionals%40yahoogroups.com>
Subject: [MS_AccessPros] catalogue the properties and their values for a
custom
class instance

Here's what I want to do: catalogue the properties and their values in an
instance of a class.

Here's why:

I am using a custom class to perform a complex set of calculations. In one
instance I perform the calculations across all records in the relevant
table. In the other instance I am performing the same calculations across a
subset of records from the same table. Because of the nature of the
calculation, a number of properties must be assigned starting values.

My problem at the moment is that the first instance appears to be performing
the calculation correctly. However the second instance is producing a result
that is orders of magnitude out of the expected range of possible results.
The results should be percentages; the calculated result is > 900.

I've tried manually going through the code and looking at values in the
debugger to try to identify where the second instance's calculation is going
wrong with no luck. So what I would like to do is use a procedure to step
through all properties using the for each structure to list the property
name and current value for each property in the instance.

My thinking is that if I can compare the two lists side by side I should be
identify what I have failed to initialize in the second instance.

Glenn

I'm desparate so I am posting this to several resources so you may see this
same message several times.

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar