Private Sub 提交_Click()
On Error GoTo Err_提交_Click
Dim i, j As Integer
Dim StrTemp As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim Rs1 As ADODB.Recordset
Set Rs1 = New ADODB.Recordset
Dim Rs2 As ADODB.Recordset
Set Rs2 = New ADODB.Recordset
StrTemp = "Select * From 申购单"
rs.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
StrTemp = "Select * From 申购单历史"
Rs1.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
StrTemp = "Select * From 采购单"
Rs2.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'如果“领料申请单”为空,则退出
If rs.RecordCount <= 0 Then
Exit Sub
End If
rs.MoveFirst
For i = 0 To rs.RecordCount - 1
CunZai = False
If Rs1.RecordCount < 1 And Rs2.RecordCount < 1 Then
CunZai = False
For j = 0 To Rs1.RecordCount - 1 And Rs2.RecordCount - 1
If Rs1("PH") = rs("PH") And Rs2("PH") = rs("PH") Then
Rs1.Update
Rs2.Update
CunZai = True
Exit For
Else
Rs1.MoveNext
Rs2.MoveNext
End If
Next j
End If