|
用事务试一下:- Dim rst As Object
- Dim strSQL As String
- Dim lngAffected As Long
- If MsgBox("是否保存批量排期操作?", vbQuestion + vbYesNo, "保存提示") = vbYes Then
- With Me.子窗体_排期表.Form.Recordset
- If .RecordCount > 0 Then
- tcnndb.BeginTrans
- .MoveFirst
- Do Until .EOF
- strSQL = "UPDATE 排期表 SET 预计加工日期=#" & !预计加工日期 & "#,预计完成日期=#" & !预计完成日期 & "#," & _
- "模号='" & !模号 & "',注塑机='" & !注塑机 & "',备注='" & !备注 & "' WHERE pqid=" & pqid
- tcnndb.Execute strSQL, lngAffected
- If lngAffected = 0 Then
- strSQL = "INSERT INTO 排期表(预计加工日期,预计完成日期,模号,注塑机,备注) " & _
- "VALUES(#" & !预计加工日期 & "#,#" & !预计完成日期 & "#,'" & !模号 & "','" & !注塑机 & "','" & !备注 & "')"
- tcnndb.Execute strSQL
- End If
- .MoveNext
- Loop
- tcnndb.CommitTrans
- MsgBox "保存成功!"
- End If
- End With
- Else
- GoSub err01
- End If
复制代码 |
|