Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1194
Number of posts: 2247

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
serious expertise needed updating recordsets with SQL Posted by peterscott64 on 10 Aug 2003 at 12:33 PM
I need HELP! O(o_o)O
---------------------------

I am suriously stuck, Debugging code without documentation is a nightmare for trainee programmers.

Basically I need to loop a record set called Summary and Validate all informtion containned within it, I assume the way I can accomplish the task but am not sure how to implement it, right next within the loop I have to grab a value from a field called Carried Forward in that record and then set the value of Balance C/F in the next record to the grabbed Carried Foward Value from the previous record.

But this can apply to only certain records for example within my ContractorID field in the table it relates to multiple instances of certain contractors, the first instance of a contractor will contain no Balance C/F and the last instance may contain a Carried Forward value but I don't want to grab the last value because it would wreck the other records.

I think I have to create some kind of SQL statement an APPEND query but don't have the expertise. HELP ME please..

Any ideas would be nice, And also tell me if you want me to explain more, can you guys understand me?
Report
Re: serious expertise needed updating recordsets with SQL Posted by infidel on 11 Aug 2003 at 8:00 AM
: I need HELP! O(o_o)O
: ---------------------------
:
: I am suriously stuck, Debugging code without documentation is a nightmare for trainee programmers.
:
: Basically I need to loop a record set called Summary and Validate all informtion containned within it, I assume the way I can accomplish the task but am not sure how to implement it, right next within the loop I have to grab a value from a field called Carried Forward in that record and then set the value of Balance C/F in the next record to the grabbed Carried Foward Value from the previous record.
:
: But this can apply to only certain records for example within my ContractorID field in the table it relates to multiple instances of certain contractors, the first instance of a contractor will contain no Balance C/F and the last instance may contain a Carried Forward value but I don't want to grab the last value because it would wreck the other records.
:
: I think I have to create some kind of SQL statement an APPEND query but don't have the expertise. HELP ME please..
:
: Any ideas would be nice, And also tell me if you want me to explain more, can you guys understand me?

I think the easiest way to do this is with a loop. What language are you using?


infidel

Report
Re: serious expertise needed updating recordsets with SQL Posted by peterscott64 on 11 Aug 2003 at 11:21 AM
: : I need HELP! O(o_o)O
: : ---------------------------
: :
: : I am suriously stuck, Debugging code without documentation is a nightmare for trainee programmers.
: :
: : Basically I need to loop a record set called Summary and Validate all informtion containned within it, I assume the way I can accomplish the task but am not sure how to implement it, right next within the loop I have to grab a value from a field called Carried Forward in that record and then set the value of Balance C/F in the next record to the grabbed Carried Foward Value from the previous record.
: :
: : But this can apply to only certain records for example within my ContractorID field in the table it relates to multiple instances of certain contractors, the first instance of a contractor will contain no Balance C/F and the last instance may contain a Carried Forward value but I don't want to grab the last value because it would wreck the other records.
: :
: : I think I have to create some kind of SQL statement an APPEND query but don't have the expertise. HELP ME please..
: :
: : Any ideas would be nice, And also tell me if you want me to explain more, can you guys understand me?
:
: I think the easiest way to do this is with a loop. What language are you using?
:
:
: infidel
:
:
Hi I'm using access and VBA code this is what I have but there must be a simple way! and more effecient way am thinkin SQL but don't know take a look tell me what u think.

Dim lp As Integer
Dim rf As Double
Dim ConName As String
Dim cnt As Integer

Set RS = Me.RecordsetClone


RS.MoveFirst
ConName = RS![CONTRACTOR_ID]
temp = RS![C/F]
RS.MoveNext
If ConName = RS![CONTRACTOR_ID] Then
RS.Edit
RS![BalanceC/F] = temp
RS.UPDATE
ConName = RS![CONTRACTOR_ID]
temp = RS![C/F]
cnt = 2
RS.MoveNext
End If
While Not RS.EOF
If ConName <> RS![CONTRACTOR_ID] Then
RS.Edit
RS![BalanceC/F] = 0
RS.UPDATE
temp = RS![C/F]
ConName = RS![CONTRACTOR_ID]
RS.MoveNext

Else
RS.Edit
RS![BalanceC/F] = temp
RS.UPDATE
If cnt = RS.RecordCount - 1 Then
GoTo tat:
Else
temp = RS![C/F]
ConName = RS![CONTRACTOR_ID]
RS.MoveNext
End If
End If
cnt = cnt + 1
Wend
tat:
Set RS = Nothing

Report
Re: serious expertise needed updating recordsets with SQL Posted by infidel on 11 Aug 2003 at 11:43 AM
Ok, so the idea is that every record's BalanceCF should be set to the CF of the previous record for that contractor.

If that's the entire requirement, we should be able to come up with a SQL statement. We need to know how your record are ordered, though. By contractor_id and what? There must be some date or number you are sorting by, yes?


infidel

Report
Re: serious expertise needed updating recordsets with SQL Posted by peterscott64 on 11 Aug 2003 at 11:57 AM
This message was edited by peterscott64 at 2003-8-11 12:1:3

I think this part will give us trouble as the the Contractor ID field is made up of a National Insurance number another number and the persons surname something like this yh 45 75 34 B14544317Scott it is indexed but can contain multiple entries by the same contractor. it is in this order asending numbers in the contractors ID then asending letters.

; ) any idea man?


Report
Re: serious expertise needed updating recordsets with SQL Posted by infidel on 11 Aug 2003 at 12:42 PM
: This message was edited by peterscott64 at 2003-8-11 12:1:3

: I think this part will give us trouble as the the Contractor ID field is made up of a National Insurance number another number and the persons surname something like this yh 45 75 34 B14544317Scott it is indexed but can contain multiple entries by the same contractor. it is in this order asending numbers in the contractors ID then asending letters.
:
: ; ) any idea man?

Holy crap. If that's the only thing you sort by, how do you know you're putting the right CF value in the right BalanceCF field?


infidel




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.