张老师,还是不行啊
Option Compare Database
Option Explicit
Public Function InitData()
ClearControlValues Me
End Function
Private Sub Form_Load()
ApplyTheme Me
LoadLocalLanguage Me
If Nz(Me.OpenArgs) <> "" Then
LoadRecord Me, "SELECT * FROM [运行日报表] WHERE [序号]=" & Nz(Me.OpenArgs, 0)
End If
If Me.DataEntry Then
Me![序号] = Null
End If
Me.btnSave.Enabled = Me.AllowEdits
End Sub
Private Sub btnSave_Click()
On Error GoTo ErrorHandler
If Not CheckRequired(Me) Then Exit Sub
If Not CheckTextLength(Me) Then Exit Sub
Dim cnn: Set cnn = CurrentProject.Connection
'cnn.BeginTrans
'Dim blnTransBegin As Boolean: blnTransBegin = True
Dim strSQL: strSQL = "SELECT * FROM [运行日报表] WHERE [序号]=" & Nz(Me![序号], 0)
Dim rst: Set rst = ADO.OpenRecordset(strSQL, adLockOptimistic, cnn)
If rst.EOF Then
rst.AddNew
rst!操作员 = GetParameter("Current User Username")
rst!操作时间 = Now()
End If
UpdateRecord Me, rst
'你的自定义代码
'rst!Field1 = Me!Field1
'rst!Field2 = Me!Field2
rst.Update
rst.Close
'cnn.CommitTrans
'blnTransBegin = False
RequeryDataObject gsfrList
MsgBoxEx LoadString("Saved Successfully."), vbInformation
If Me.DataEntry Then
Me.InitData
Else
DoCmd.Close acForm, Me.Name, acSaveNo
End If
ExitHere:
Set rst = Nothing
Set cnn = Nothing
Exit Sub
ErrorHandler:
'If blnTransBegin Then
' cnn.RollbackTrans
' blnTransBegin = False
'End If
RDPErrorHandler Me.Name & ": Sub btnSave_Click()"
Resume ExitHere
End Sub
Private Sub btnCancel_Click()
On Error Resume Next
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub