|
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
Rs1.AddNew
Rs1("SGDH") = Me![SGDH]
Rs2("CGDH") = Me![SGDH]
Rs1("YJRQ") = Me![YJRQ]
Rs1("SGR") = Me![SGR]
Rs1("SGBM") = Me![SGBM]
Rs1("SGRQ") = Me![SGRQ]
Rs1("SHR") = Me![SHR]
Rs1("SHRQ") = Me![SHRQ]
Rs1("HZR") = Me![HZR]
Rs1("HZRQ") = Me![HZRQ]
Rs1("GES") = Me![GES]
Rs2("CS") = Me![GES]
Rs1("PH") = rs("PH")
Rs2("PH") = rs("PH")
Rs1("PMPE") = rs("PMPE")
Rs2("PMPE") = rs("PMPE")
Rs1("PM") = rs("PM")
Rs2("PM") = rs("PM")
Rs1("LB") = rs("LB")
Rs2("LB") = rs("LB")
Rs1("PP") = rs("PP")
Rs2("PP") = rs("PP")
Rs1("GG") = rs("GG")
Rs2("GG") = rs("GG")
Rs1("DW") = rs("DW")
Rs2("DW") = rs("DW")
Rs1("MJFH") = rs("MJFH")
Rs2("MJFH") = rs("MJFH")
Rs1("GCH") = rs("GCH")
Rs2("GCH") = rs("GCH")
Rs1("SGSL") = rs("SGSL")
Rs2("SGSL") = rs("SGSL")
Rs1("BZ") = rs("BZ")
Rs2("BZ") = rs("BZ")
Rs1("SZBH") = rs("SZBH")
Rs2("SZBH") = rs("SZBH")
Rs1.Update
'删除申购单该条记录
rs.Delete 1
'Me![申购单子窗体].Requery
rs.MoveNext
Next i
Set rs = Nothing
Set Rs1 = Nothing
Me![申购单子窗体].Requery
MsgBox "申购单已经提交成功", vbInformation, "温馨提示"
Exit_提交_Click:
Set rs = Nothing
Set Rs1 = Nothing
Exit Sub
Err_提交_Click:
MsgBox Err.Description
Resume Exit_提交_Click
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|