主题:[讨论](菜鸟问题)那位大侠帮帮小弟?vb+access中的field()属性问题.
Case "check_date" '按入库单+日期汇总
Label1.Caption = "按来料规格+日期汇总"
sql = "select 来料规格,日期,sum(数量) as 总金额 from 来料录入 " & _
"group by 来料规格,日期 order by sum(数量)"
rs_sum.CursorLocation = adUseClient
rs_sum.Open sql, conn, adOpenKeyset, adLockPessimistic
addup = 0
MSFlexGrid1.MergeCells = flexMergeRestrictRows
MSFlexGrid1.MergeCol(0) = True
MSFlexGrid1.Rows = rs_sum.RecordCount + 2
MSFlexGrid1.Rows = rs_sum.RecordCount + 2 '不一样
MSFlexGrid1.Cols = 3 '不一样
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "来料规格"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "来料日期"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "总数量"
'MSFlexGrid1.Col = 3
'MSFlexGrid1.Text = "情况"
If rs_sum.EOF = False Then
rs_sum.MoveFirst
Do While Not rs_sum.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = rs_sum.Fields(0)
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = rs_sum.Fields(1)
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = rs_sum.Fields(3) '问题就出在这条语句上,不知道为什么?该如何解决?这条语句和上条语句(即MSFlexGrid1.Col = 3、MSFlexGrid1.Text = rs_sum.Fields(3))是我自己添加的,没有这两条语句,程序能正常运行。
MSFlexGrid1.Col = 2
If CDbl(rs_sum.Fields(2)) < 0 Then
MSFlexGrid1.Text = Replace(rs_sum.Fields(2), "-", "")
Else
MSFlexGrid1.Text = rs_sum.Fields(2)
End If
addup = addup + CDbl(rs_sum.Fields(2))
rs_sum.MoveNext
Loop
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "(总计)"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = addup
End If
rs_sum.Close
Label1.Caption = "按来料规格+日期汇总"
sql = "select 来料规格,日期,sum(数量) as 总金额 from 来料录入 " & _
"group by 来料规格,日期 order by sum(数量)"
rs_sum.CursorLocation = adUseClient
rs_sum.Open sql, conn, adOpenKeyset, adLockPessimistic
addup = 0
MSFlexGrid1.MergeCells = flexMergeRestrictRows
MSFlexGrid1.MergeCol(0) = True
MSFlexGrid1.Rows = rs_sum.RecordCount + 2
MSFlexGrid1.Rows = rs_sum.RecordCount + 2 '不一样
MSFlexGrid1.Cols = 3 '不一样
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "来料规格"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "来料日期"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "总数量"
'MSFlexGrid1.Col = 3
'MSFlexGrid1.Text = "情况"
If rs_sum.EOF = False Then
rs_sum.MoveFirst
Do While Not rs_sum.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = rs_sum.Fields(0)
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = rs_sum.Fields(1)
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = rs_sum.Fields(3) '问题就出在这条语句上,不知道为什么?该如何解决?这条语句和上条语句(即MSFlexGrid1.Col = 3、MSFlexGrid1.Text = rs_sum.Fields(3))是我自己添加的,没有这两条语句,程序能正常运行。
MSFlexGrid1.Col = 2
If CDbl(rs_sum.Fields(2)) < 0 Then
MSFlexGrid1.Text = Replace(rs_sum.Fields(2), "-", "")
Else
MSFlexGrid1.Text = rs_sum.Fields(2)
End If
addup = addup + CDbl(rs_sum.Fields(2))
rs_sum.MoveNext
Loop
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "(总计)"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = addup
End If
rs_sum.Close