好:
小弟刚接触,对会做录入窗体,看到红尘如烟的一个半绑定录入窗体,不明白代码的意思,请求大家帮忙加下注释,代码如下(已上传附件):
Option Compare Database
Option Explicit
Private Sub cmdAdd_Click()
On Error Resume Next
Dim ctl As Control
For Each ctl In Me.Controls
ctl.Value = Null
Next
Me.Recordset.AddNew
End Sub
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
Dim i As Integer
Dim rs As New ADODB.Recordset
DoCmd.RunCommand acCmdSaveRecord
End If
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
If Err.Number = 3022 Then
MsgBox "必填项均不允许重复操作被撤消", vbCritical
Me.Undo
Call Form_Current
Else
MsgBox Err.Number & Chr(13) & Err.Description
End If
Resume Exit_cmdSave_Click
End Sub
Private Sub cmdUndo_Click()
Call Form_Current
End Sub
Private Sub Form_Current()
On Error Resume Next
Dim ctl As Control
If Me.NewRecord Then
Call cmdAdd_Click
Else
For Each ctl In Me.Controls
ctl.Value = Me.Recordset("F" & Mid(ctl.Name, 4))
Next
End If
End Sub
Private Sub Form_Load()
End Sub作者: t小宝 时间: 2010-6-23 21:48
看书学习!