回复 21# happynight 的帖子
明天可以嗎?Dim i As Integer
Private Sub Command1_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "琩高兵ンぃ???!"
Exit Sub
Else
cn.Execute " delete from t_cgamt
where left(TH002,8) between '" & Text1.Text & "' and '" & Text2.Text & "'"
strquery = "insert into t_cgamt select TH001,TH002,TH004,TH005,TH006,TH007,TG017,MB064,amt=TH007 * TG017,ljamt=0
from PURTG LEFT JOIN PURTH ON TG001=TH001 AND TG002=TH002 LEFT JOIN INVMB ON TH004=MB001 WHERE left(TH002,8) between '" & Text1.Text & "' and '" & Text2.Text & "'"
= 0
cn.Execute strquery
Set rs = Nothing
rs.CursorLocation = adUseClient
rs.Open "select * from t_cgamt where left(TH002,8) between '" & Text1.Text & "' and '" & Text2.Text & "'", cn, 3, 2
MSFcase.Rows = 2
For j = 0 To MSFcase.Cols - 1
MSFcase.TextMatrix(MSFcase.Row, j) = ""
Next
'
Set RS1 = Nothing
'
RS1.Open "select TH001,TH002,TH004,TH005,TH006,TH007,TG017,MB064,amt=TH007 * TG017,ljamt=0
from PURTG LEFT JOIN PURTH ON TG001=TH001 AND TG002=TH002 LEFT JOIN INVMB ON TH004=MB001 WHERE left(TH002,8) between '" & Text1.Text & "' and '" & Text2.Text & "'", cn, 3, 2
'
Call AddRecordtoMSFcase(MSFcase, RS1)
'仓??肂=羆?肂+羆?肂
MSFcase.TextMatrix(1, 9) = Round(Val(MSFcase.TextMatrix(MSFcase.Row, 8)) + Val(MSFcase.TextMatrix(MSFcase.Row, 8)), 2)
For i = 1 To MSFcase.Rows - 1
MSFcase.TextMatrix(MSFcase.Rows - 1, 9) = Round(Val(MSFcase.TextMatrix(MSFcase.Rows - 1, 8)) + Val(MSFcase.TextMatrix(MSFcase.Rows - 1, 8)), 2)
MSFcase.TextMatrix(MSFcase.Rows - 1, 9) = MSFcase.TextMatrix(MSFcase.Rows - 1, 9) + MSFcase.TextMatrix(MSFcase.Rows - 1, 9)
Next
End If
If rs.RecordCount >= 1 Then
Do While Not rs.EOF
Set xrs = Nothing
xrs.CursorLocation = adUseClient
xrs.Open "select TH001,TH002,TH004,TH005,TH006,TH007,TG017,MB064,amt=TH007 * TG017,ljamt=0
from PURTG LEFT JOIN PURTH ON TG001=TH001 AND TG002=TH002 LEFT JOIN INVMB ON TH004=MB001 WHERE left(TH002,8) between '" & Text1.Text & "' and '" & Text2.Text & "'", cn, 3, 2
If xrs.RecordCount >= 1 Then
Do While Not xrs.EOF
cn.Execute "update t_cgamt set ljamt=" & xrs.Fields(8) & " where left(TH002,8) between '" & Text1.Text & "' and '" & Text2.Text & "'"
xrs.MoveNext
Loop
End If
End Sub
這是我做的代碼有錯啊麻煩你了