|
4#
楼主 |
发表于 2019-3-12 15:32:54
|
只看该作者
'保存按钮
Private Sub cmdSave_Click()
On Error GoTo ErrorHandler
Dim strSql As String
Dim cn As Object
Dim rs As Object
'【事务处理】
Set cn = CurrentProject.Connection
cn.BeginTrans '开始事务
'【保存数据】
strSql = "Select * from [Tbl_BuyPOTmp]"
Set rs = gf_OpenRecordset(strSql, cn, 1, 3)
If rs.EOF = False Then
Dim strMessage As String: strMessage = gf_GetLangValue("Are you sure to Save?")
If Not gf_Msgbox(strMessage, vbExclamation + vbOKCancel) = vbOK Then Exit Sub
DoCmd.RunSQL "INSERT INTO Tbl_BuyPO (Bu_ID, Bu_IDFT, Bu_PrID, Bu_Pdid, Bu_PiID, Bu_Qty, Bu_Stock, Bu_Date, Bu_NeedDate, Bu_LkID, Bu_EmID," & _
" Bu_EmAudit, Bu_Audit, Bu_Audate, Bu_Seid, Bu_Memo, Bu_InFinish, Bu_Active ) SELECT Tbl_BuyPOTmp.Bu_ID, Tbl_BuyPOTmp.Bu_IDFT," & _
" Tbl_BuyPOTmp.Bu_PrID, Tbl_BuyPOTmp.Bu_Pdid, Tbl_BuyPOTmp.Bu_PiID, Tbl_BuyPOTmp.Bu_Qty, Tbl_BuyPOTmp.Bu_Stock, Tbl_BuyPOTmp.Bu_Date, Tbl_BuyPOTmp.Bu_NeedDate," & _
" Tbl_BuyPOTmp.Bu_LkID, Tbl_BuyPOTmp.Bu_EmID, Tbl_BuyPOTmp.Bu_EmAudit, Tbl_BuyPOTmp.Bu_Audit, Tbl_BuyPOTmp.Bu_Audate, Tbl_BuyPOTmp.Bu_Seid, Tbl_BuyPOTmp.Bu_Memo," & _
" Tbl_BuyPOTmp.Bu_InFinish, Tbl_BuyPOTmp.Bu_Active FROM Tbl_BuyPOTmp;"
DoCmd.RunSQL "delete Tbl_BuyPoTmp.* from Tbl_BuyPoTmp"
gf_RequerySubForm Forms![frm__BuyPO_Main]![sfmSubForm] 这句好象不起作用
gf_Msgbox gf_GetLangValue("Save Successfully")
DoCmd.Close acForm, Me.Name, acSaveNo
Else
gf_Msgbox "没有采购记录需要保存!"
End If
ExitHere:
Set rs = Nothing
Set cn = Nothing
Exit Sub
ErrorHandler:
Resume ExitHere
End Sub
|
|