cyle
asked on
Logic Help!
Experts, I'm logically confused right now can anyone help? Thanks.
I have this code that grabs data from another source and dumps it in these fields......But (AMT) needs to be added based on LOC. And when it loads in the field then it will give me one LOC, NAME and one sum AMT.
Call ores.Execute
If (ores.NumRows <> 0) Then
rowCTR = 1
Do
ores.NextRow
If (ores.GetError = DBstsSUCCESS) Then
Set doc = New NotesDocument(db)
' Setting fields area
doc.location = Trim(ores.GetValue("LOC"))
doc.locationname = Trim(ores.GetValue("NAME") )
????
amount = ores.GetValue("AMT")
Tamount = Tamount + amount
doc.period01 = Tamount
????
'set fields here
'load form
doc.form = "Monthly Data"
Call doc.Save(True,False)
Else
Msgbox "Error: " & ores.GetError & Error$
End If
rowCTR = rowCTR + 1
Loop Until ores.IsEndOfData
I have this code that grabs data from another source and dumps it in these fields......But (AMT) needs to be added based on LOC. And when it loads in the field then it will give me one LOC, NAME and one sum AMT.
Call ores.Execute
If (ores.NumRows <> 0) Then
rowCTR = 1
Do
ores.NextRow
If (ores.GetError = DBstsSUCCESS) Then
Set doc = New NotesDocument(db)
' Setting fields area
doc.location = Trim(ores.GetValue("LOC"))
doc.locationname = Trim(ores.GetValue("NAME")
????
amount = ores.GetValue("AMT")
Tamount = Tamount + amount
doc.period01 = Tamount
????
'set fields here
'load form
doc.form = "Monthly Data"
Call doc.Save(True,False)
Else
Msgbox "Error: " & ores.GetError & Error$
End If
rowCTR = rowCTR + 1
Loop Until ores.IsEndOfData
Could you tell us in pseudo-code what you want?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good guesswork, but where does the Save come in?? The algorithm doe shave some flaws, I think...
ASKER
He does have the right idea, I saved after the loop is finished but LOC is more than one and it should display based on LOC like this:
LOC: 100
TAmount: 12,000.00
LOC: 200
TAmount: 11,000.00
location = Trim(ores.GetValue("LOC"))
amount = ores.GetValue("AMT")
If IsElement(Tamount(location )) Then
Tamount(location) = Tamount(location) + amount
Else
Tamount(location) = amount
End If
Else
Msgbox "Error: " & ores.GetError & Error$
End If
rowCTR = rowCTR + 1
Loop Until ores.IsEndOfData
'load form
doc.period01 = Tamount
doc.form = "Monthly Data"
Call doc.Save(True,False)
ocon.Disconnect
LOC: 100
TAmount: 12,000.00
LOC: 200
TAmount: 11,000.00
location = Trim(ores.GetValue("LOC"))
amount = ores.GetValue("AMT")
If IsElement(Tamount(location
Tamount(location) = Tamount(location) + amount
Else
Tamount(location) = amount
End If
Else
Msgbox "Error: " & ores.GetError & Error$
End If
rowCTR = rowCTR + 1
Loop Until ores.IsEndOfData
'load form
doc.period01 = Tamount
doc.form = "Monthly Data"
Call doc.Save(True,False)
ocon.Disconnect
cyle,
> doc.period01 = Tamount
You can't do that with a List, it cannot be stored. So you have to do soemthing different with it. Several ways:
1) you put everything in text, if you don't need to use it for computations at some later moment (see also Qwaletee's answer)
2) you put it into two multi-value fields in the document, one for the locations and one for the values
3) you create (or use) response documents to store location names and values (inefficient if that's all to be stored)
What's it to be?
Sjef
> doc.period01 = Tamount
You can't do that with a List, it cannot be stored. So you have to do soemthing different with it. Several ways:
1) you put everything in text, if you don't need to use it for computations at some later moment (see also Qwaletee's answer)
2) you put it into two multi-value fields in the document, one for the locations and one for the values
3) you create (or use) response documents to store location names and values (inefficient if that's all to be stored)
What's it to be?
Sjef