PC Review


Reply
Thread Tools Rate Thread

Commenting Code - recordsets

 
 
=?Utf-8?B?RGVyZWsgV2l0dG1hbg==?=
Guest
Posts: n/a
 
      14th Jun 2004
Good morning,
I'm seriously challenged today to remember why I did some of the things in this code. I need to modify it for another part of the application (not a part of CigLogic functionality), and I cannot remember why I reset variables on which lines I did. Fortunately, I remember why I needed the movenexts and movepreviouses where they are. I thought I had enough commenting for myself, but I guess I am wrong. Can someone please give me a hand? Thank you very much in advance!

Derek

Code:
Sub CigLogic()

Dim dbs As DAO.Database, rstCumArm1 As DAO.Recordset
Dim curInter, curToCase, cur6s, cur2s, cur1s As Double
Dim previnter, curCumArm, nextCumArm As Integer

'Setting up the recordset
Set dbs = CurrentDb
Set rstCumArm1 = dbs.OpenRecordset("CumArm1", dbOpenTable)
With rstCumArm1
.MoveLast
.MoveFirst 'my record of 0's. I'm not working calculations on this one.
.MoveNext
While Not .EOF 'starting my loop (supposedly...)
curInter = 0 'reset curInter (why am I doing this inside the loop?)
.MovePrevious
previnter = !inter 'put (X-1) value of 'inter' field to previnter
.MoveNext
.MoveNext
If .EOF Then
nextCumArm = 0
Else: nextCumArm = !CumArm 'put (X+1) value of CumArm to nextCumArm
End If
.MovePrevious
If previnter + !CumArm + nextCumArm > 12 Then 'start making decisions - if TRUE then start putting from arm into case
curInter = 0
curToCase = previnter + !CumArm
cur6s = Int(curToCase / 6)
cur2s = Int((curToCase - cur6s * 6) / 2)
cur1s = curToCase - 6 * cur6s - 2 * cur2s
Else: curInter = previnter + !CumArm 'since it's not TRUE then continue to accummulate into arm
curToCase = 0
cur6s = 0
cur2s = 0
cur1s = 0
End If

.Edit 'time to start updating the recordset to the held variable values
!inter = curInter
!tocase = curToCase
![6s] = cur6s
![2s] = cur2s
![1s] = cur1s
!TimeSt = Now()
.Update 'time to move the values from the recordset to the datatable
.MoveNext
Wend 'supposedly to go back to the WHILE NOT start
.Close
End With
CurrentDb.Close
Set rstCumArm1 = Nothing
Set dbs = Nothing
DoCmd.RunSQL ("Delete * from CumArm1 where TimeSt = dmin('[TimeSt]','CumArm1','')")
End If
End Sub

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGVyZWsgV2l0dG1hbg==?=
Guest
Posts: n/a
 
      14th Jun 2004
Never mind... I figured it out.

"Derek Wittman" wrote:

> Good morning,
> I'm seriously challenged today to remember why I did some of the things in this code. I need to modify it for another part of the application (not a part of CigLogic functionality), and I cannot remember why I reset variables on which lines I did. Fortunately, I remember why I needed the movenexts and movepreviouses where they are. I thought I had enough commenting for myself, but I guess I am wrong. Can someone please give me a hand? Thank you very much in advance!
>
> Derek
>
> Code:
> Sub CigLogic()
>
> Dim dbs As DAO.Database, rstCumArm1 As DAO.Recordset
> Dim curInter, curToCase, cur6s, cur2s, cur1s As Double
> Dim previnter, curCumArm, nextCumArm As Integer
>
> 'Setting up the recordset
> Set dbs = CurrentDb
> Set rstCumArm1 = dbs.OpenRecordset("CumArm1", dbOpenTable)
> With rstCumArm1
> .MoveLast
> .MoveFirst 'my record of 0's. I'm not working calculations on this one.
> .MoveNext
> While Not .EOF 'starting my loop (supposedly...)
> curInter = 0 'reset curInter (why am I doing this inside the loop?)
> .MovePrevious
> previnter = !inter 'put (X-1) value of 'inter' field to previnter
> .MoveNext
> .MoveNext
> If .EOF Then
> nextCumArm = 0
> Else: nextCumArm = !CumArm 'put (X+1) value of CumArm to nextCumArm
> End If
> .MovePrevious
> If previnter + !CumArm + nextCumArm > 12 Then 'start making decisions - if TRUE then start putting from arm into case
> curInter = 0
> curToCase = previnter + !CumArm
> cur6s = Int(curToCase / 6)
> cur2s = Int((curToCase - cur6s * 6) / 2)
> cur1s = curToCase - 6 * cur6s - 2 * cur2s
> Else: curInter = previnter + !CumArm 'since it's not TRUE then continue to accummulate into arm
> curToCase = 0
> cur6s = 0
> cur2s = 0
> cur1s = 0
> End If
>
> .Edit 'time to start updating the recordset to the held variable values
> !inter = curInter
> !tocase = curToCase
> ![6s] = cur6s
> ![2s] = cur2s
> ![1s] = cur1s
> !TimeSt = Now()
> .Update 'time to move the values from the recordset to the datatable
> .MoveNext
> Wend 'supposedly to go back to the WHILE NOT start
> .Close
> End With
> CurrentDb.Close
> Set rstCumArm1 = Nothing
> Set dbs = Nothing
> DoCmd.RunSQL ("Delete * from CumArm1 where TimeSt = dmin('[TimeSt]','CumArm1','')")
> End If
> End Sub
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Commenting out code =?Utf-8?B?SmVmZg==?= Microsoft Excel Misc 2 31st Jan 2007 07:18 PM
Commenting on Code Carlthomas Microsoft Excel Programming 0 2nd May 2006 12:40 AM
Commenting out VB code =?Utf-8?B?U2FuZHk=?= Microsoft ASP .NET 5 3rd Feb 2005 05:51 PM
Commenting in Code Paul Black Microsoft Excel Programming 7 9th Oct 2004 08:18 PM
Re: Commenting Out Code in Bulk Albert D. Kallal Microsoft Access VBA Modules 0 9th Jul 2003 09:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:38 PM.