Set rs2 = New ADODB.Recordset
conn2.ConnectionString = JetOLEDB
conn2.Open
rs2.Open "select * from Store where ProId='" & MS1.TextMatrix(i, 1) & "'", conn2, 1,3
If rs2.RecordCount = 0 Then
rs2.AddNew
If MS1.TextMatrix(i, 1) <> "" Then rs2.Fields("ProId") = MS1.TextMatrix(i, 1)
If MS1.TextMatrix(i, 5) <> "" Then rs2.Fields("Quantity") = MS1.TextMatrix(i, 5)
If Label5.Caption <> "" Then rs2.Fields("indate") = Label5.Caption
rs2.Update
Else
Adodc4.Recordset.Fields("Quantity") = Val(MS1.TextMatrix(i, 5)) + Val(Adodc4.Recordset.Fields("Quantity"))
End If
rs2.Close
conn2.Close
End If为什么符合这个条件还进入else???
If rs2.RecordCount = 0 Then
rs2.AddNew
If MS1.TextMatrix(i, 1) <> "" Then rs2.Fields("ProId") = MS1.TextMatrix(i, 1)
If MS1.TextMatrix(i, 5) <> "" Then rs2.Fields("Quantity") = MS1.TextMatrix(i, 5)
If Label5.Caption <> "" Then rs2.Fields("indate") = Label5.Caption
rs2.Update
conn2.ConnectionString = JetOLEDB
conn2.Open
rs2.Open "select * from Store where ProId='" & MS1.TextMatrix(i, 1) & "'", conn2, 1,3
If rs2.RecordCount = 0 Then
rs2.AddNew
If MS1.TextMatrix(i, 1) <> "" Then rs2.Fields("ProId") = MS1.TextMatrix(i, 1)
If MS1.TextMatrix(i, 5) <> "" Then rs2.Fields("Quantity") = MS1.TextMatrix(i, 5)
If Label5.Caption <> "" Then rs2.Fields("indate") = Label5.Caption
rs2.Update
Else
Adodc4.Recordset.Fields("Quantity") = Val(MS1.TextMatrix(i, 5)) + Val(Adodc4.Recordset.Fields("Quantity"))
End If
rs2.Close
conn2.Close
End If为什么符合这个条件还进入else???
If rs2.RecordCount = 0 Then
rs2.AddNew
If MS1.TextMatrix(i, 1) <> "" Then rs2.Fields("ProId") = MS1.TextMatrix(i, 1)
If MS1.TextMatrix(i, 5) <> "" Then rs2.Fields("Quantity") = MS1.TextMatrix(i, 5)
If Label5.Caption <> "" Then rs2.Fields("indate") = Label5.Caption
rs2.Update
你输出一下rs2.RecordCount 的值看看
参考:
http://www.china-askpro.com/msg21/qa32.shtml
單步測試一下確定有沒有進入else
就好了