S
scorpion53061
The code below is suppose to take data from a dataset and total it by
month.
What it is doing is best represented by a spreadsheet. It seems to be
completely ignoring the filter set down.
PLEASE look and suggest something....
http://www.kjmsolutions.com/ibou.ZIP
Dim foundrows As DataRow()
Dim r As DataRow
Dim rowcount As Integer
Dim strexpression As String
Dim alreadyexists As Boolean
Dim r1 As DataRow
Dim drnew1 As DataRow
Dim itemcheck1 As Integer
For itemcheck = 0 To dstrancopy.Tables(0).Rows.Count - 1
strexpression = "ITEM = '" &
dstrancopy.Tables(0).Rows(itemcheck).Item("ITEM") & "'"
drnew1 = listds.Tables(0).NewRow
drnew1.Item("ITEMNO") =
dstrancopy.Tables(0).Rows(itemcheck).Item("ITEM")
foundrows = dstrancopy.Tables(0).Select(strexpression)
MsgBox(foundrows.Length)
For Each r1 In foundrows
For itemcheck1 = 0 To listds.Tables(0).Rows.Count - 1
If listds.Tables(0).Rows(itemcheck1).Item("ITEMNO") =
r1.Item("ITEM") Then
alreadyexists = True
Exit For
Else
alreadyexists = False
End If
Next
If alreadyexists = False Then
drnew1.Item("JAN") = r.Table.Compute(r1.Item("UCOST") *
r1.Item("QTY"), "(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE
<> 'RGA') and (DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "1/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "01/")
drnew1.Item("JANQTY") = r1.Table.Compute(r1.Item("QTY"),
"(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE <> 'RGA') and
(DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "1/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "01/")
drnew1.Item("FEB") = r1.Table.Compute(r1.Item("UCOST") *
r1.Item("QTY"), "(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE
<> 'RGA') and (DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "2/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "02/")
drnew1.Item("FEBQTY") = r1.Table.Compute(r1.Item("QTY"),
"(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE <> 'RGA') and
(DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "2/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "02/")
listds.Tables(0).Rows.Add(drnew1)
End If
Next
Next
month.
What it is doing is best represented by a spreadsheet. It seems to be
completely ignoring the filter set down.
PLEASE look and suggest something....
http://www.kjmsolutions.com/ibou.ZIP
Dim foundrows As DataRow()
Dim r As DataRow
Dim rowcount As Integer
Dim strexpression As String
Dim alreadyexists As Boolean
Dim r1 As DataRow
Dim drnew1 As DataRow
Dim itemcheck1 As Integer
For itemcheck = 0 To dstrancopy.Tables(0).Rows.Count - 1
strexpression = "ITEM = '" &
dstrancopy.Tables(0).Rows(itemcheck).Item("ITEM") & "'"
drnew1 = listds.Tables(0).NewRow
drnew1.Item("ITEMNO") =
dstrancopy.Tables(0).Rows(itemcheck).Item("ITEM")
foundrows = dstrancopy.Tables(0).Select(strexpression)
MsgBox(foundrows.Length)
For Each r1 In foundrows
For itemcheck1 = 0 To listds.Tables(0).Rows.Count - 1
If listds.Tables(0).Rows(itemcheck1).Item("ITEMNO") =
r1.Item("ITEM") Then
alreadyexists = True
Exit For
Else
alreadyexists = False
End If
Next
If alreadyexists = False Then
drnew1.Item("JAN") = r.Table.Compute(r1.Item("UCOST") *
r1.Item("QTY"), "(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE
<> 'RGA') and (DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "1/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "01/")
drnew1.Item("JANQTY") = r1.Table.Compute(r1.Item("QTY"),
"(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE <> 'RGA') and
(DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "1/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "01/")
drnew1.Item("FEB") = r1.Table.Compute(r1.Item("UCOST") *
r1.Item("QTY"), "(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE
<> 'RGA') and (DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "2/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "02/")
drnew1.Item("FEBQTY") = r1.Table.Compute(r1.Item("QTY"),
"(TYPE <> 'CASH CREDIT' OR TYPE <> 'INVOICE CREDIT' OR TYPE <> 'RGA') and
(DATE = " &
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 2),
String) = "2/" Or
CType(Microsoft.VisualBasic.Strings.Left(r1.Item("DATE".ToString), 3),
String) = "02/")
listds.Tables(0).Rows.Add(drnew1)
End If
Next
Next