If rs1.RecordCount > 0 Then
Do While rs1.EOF = False
On Error Resume Next
If a = rs1.Fields(1) Then
b = rs1.Fields(2)
j = j + 1
End If
rs1.MoveNext '記錄下移
Loop
End If
If rs6.RecordCount > 0 Then
Do While rs6.EOF = False
On Error Resume Next
If b = rs6.Fields(1) Then c = rs6.Fields(2)
rs6.MoveNext '記錄下移
Loop
End If
If rs7.RecordCount > 0 Then
Do While rs7.EOF = False
On Error Resume Next
If c = rs7.Fields(7) Then
k = rs7.Fields(8)
l = rs7.Fields(4)
End If
rs7.MoveNext '記錄下移
Loop
End if
uj5u.com熱心網友回復:
Do While rs1.EOF = False and rs1.BOF = False
……
先注釋掉
‘On Error Resume Next
方便在IDE里面運行出錯時彈出對話框,點除錯后游標自動定位到出錯的陳述句。
此時可以在立即視窗中使用
? 變數名
顯示當前變數的值輔助除錯。
uj5u.com熱心網友回復:
就是在Do While rs1.EOF = False后面加and rs1.BOF = False就可以了?為什么我試了還是不行
uj5u.com熱心網友回復:
總的程式是這樣的,運行結果如下,,后面的值讀取不到啊
Private Sub Command2_Click()
a = Text2.Text
j = 0
With MS2
.Rows = 7
.Cols = 3
'定義MS1表格的列寬和表頭資訊
s = Array("600", "1400", "8000")
y = Array("序號", "資料庫", "查詢內容")
For i = 0 To 2
.ColWidth(i) = s(i) '定義表格的列寬
.TextMatrix(0, i) = y(i) '定義表頭資訊
Next i
'定義MS1表格的行號
For i = 1 To 6
.TextMatrix(i, 0) = i '為表格第0列賦值
Next i
End With
If rs1.RecordCount > 0 Then
Do While rs1.EOF = False And rs1.BOF = False
On Error Resume Next
If a = rs1.Fields(1) Then
b = rs1.Fields(2)
j = j + 1
End If
rs1.MoveNext '記錄下移
Loop
End If
If rs6.RecordCount > 0 Then
Do While rs6.EOF = False
On Error Resume Next
If b = rs6.Fields(1) Then c = rs6.Fields(2)
rs6.MoveNext '記錄下移
Loop
End If
If rs7.RecordCount > 0 Then
Do While rs7.EOF = False
On Error Resume Next
If c = rs7.Fields(7) Then
k = rs7.Fields(8)
l = rs7.Fields(4)
End If
rs7.MoveNext '記錄下移
Loop
End If
If rs8.RecordCount > 0 Then
Do While rs8.EOF = False
On Error Resume Next
If c = rs8.Fields(7) Then n = rs8.Fields(8) And p = rs8.Fields(4)
rs8.MoveNext '記錄下移
Loop
End If
If rs2.RecordCount > 0 Then
Do While rs2.EOF = False
On Error Resume Next
If c = rs2.Fields(7) Then m = rs2.Fields(4) And q = rs7.Fields(5) And e = rs2.Fields(8)
rs2.MoveNext '記錄下移
Loop
End If
If rs3.RecordCount > 0 Then
Do While rs3.EOF = False
On Error Resume Next
If c = rs3.Fields(7) Then f = rs3.Fields(4) And g = rs3.Fields(5) And h = rs3.Fields(8)
rs3.MoveNext '記錄下移
Loop
End If
If j = 1 Then
MS2.TextMatrix(1, 1) = "dgcphxtdglsjk"
MS2.TextMatrix(1, 2) = "相關聯的箱體編碼為" & b
MS2.TextMatrix(2, 1) = "xthddglsjk"
MS2.TextMatrix(2, 2) = "相關聯的垛的編碼為" & c
MS2.TextMatrix(3, 1) = "cgsjk"
MS2.TextMatrix(3, 2) = "供應商為" & l & "采購單為" & k
MS2.TextMatrix(4, 1) = "xssjk"
MS2.TextMatrix(4, 2) = "購買廠家為" & p & "銷售單為" & n
MS2.TextMatrix(5, 1) = "ccglsjk"
MS2.TextMatrix(5, 2) = "出倉倉庫為" & m & ",目的倉庫為" & q & ",出庫單為" & e
MS2.TextMatrix(6, 1) = "rcggsjk"
MS2.TextMatrix(6, 2) = "來源倉庫為" & f & ",入倉倉庫為" & g & ",入庫單為" & h
MsgBox "該產品為正品", , "提示"
Else
MS2.TextMatrix(1, 1) = "dgcphxtdglsjk"
MS2.TextMatrix(1, 2) = "該碼不存在或已被剔除"
MS2.TextMatrix(2, 1) = ""
MS2.TextMatrix(2, 2) = ""
MS2.TextMatrix(3, 1) = ""
MS2.TextMatrix(3, 2) = ""
MS2.TextMatrix(4, 1) = ""
MS2.TextMatrix(4, 2) = ""
MS2.TextMatrix(5, 1) = ""
MS2.TextMatrix(5, 2) = ""
MS2.TextMatrix(6, 1) = ""
MS2.TextMatrix(6, 2) = ""
MsgBox "該產品為假冒偽劣產品", , "提示"
End If