Hello Dr. Belhareth,
Leave the path in Global Code as "C:\sesame\ToImport.txt" for the following tests.
Replace the code in the CustNum Mass Update event with the following code
Var vData as String
Var vRecData as String
Var vItem as String
Var vCnt as Int
Var vLoop as Int
Var vRecCnt as Int
Var vRecLoop as Int
Var vQuit as Int
Var vResult as Double
writeln("gsfile contains [" + gsfile + "] #1")
SetStringArraySeparator(@Newline())
//Get all Data in the File for this Customer
vData = @SearchStringArray(gsFile, @Str(CustNum) + "..")
writeln("vData contains [" + vData + "]")
//Remove the data for this customer from the file as it is no longer needed.
gsFile = @DifferenceStringArray(gsFile, vData)
writeln("gsfile contains [" + gsfile + "] #2")
vCnt = @CountStringArray(vData)
writeln("Number of recs " + @str(vCnt))
vLoop = 1
vRecCnt= @FormResultSetTotal("NewForm0")
writeln(@str(vRecCnt) + " Records in the subform")
vRecLoop = 1
vQuit = 0
//Loop through the data from the text file
While vLoop <= vCnt
{
vRecData = @AccessStringArray(vData, vLoop)
writeln("RecData is [" + vRecData + "]")
RestoreStringArraySeparator()
//Parse apart
vItem = @AccessStringArray(vRecData, 2)
vResult = @AccessStringArray(vRecData, 3)
//Loop through the subform looking for the record that matches
While ((vRecLoop <= vRecCnt) And (vQuit = 0))
{
If @FormFieldValue("NewForm0", "Metal Type", vRecLoop) = vItem Then
{
writeln("Found a match")
//Record found. Lets put the result in the subform.
FormFieldValue("NewForm0", "Result", vRecLoop, vResult)
writeln("Value set to " + @FormFieldValue("NewForm0", "Result", vRecLoop))
If @ToMoney(@FormFieldValue("NewForm0", "Result", vRecLoop)) <> vResult Then
{
Writeln("Failed to set the result Element on record " + vRecLoop)
}
vQuit = 1
}
vRecLoop = vRecLoop + 1
}
vRecLoop = 1
vQuit = 0
SetStringArraySeparator(@Newline())
vLoop = vLoop + 1
}
Run the mass update.
Copy every thing that shows up in the WriteLn window. Ctrl C will copy from that window.
Paste it here so I can see what is happening.
-Ray