|
本帖最后由 longdoupj 于 2010-6-22 22:01 编辑
好:
小弟刚接触,对会做录入窗体,看到红尘如烟的一个半绑定录入窗体,不明白代码的意思,请求大家帮忙加下注释,代码如下(已上传附件):
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
If Nz(Me.txtForShort, "") = "" Or _
Nz(Me.txtPinYin, "") = "" _
Then
MsgBox "必填项不能为空,数据不能保存", vbCritical
Exit Sub
Else
Me![FForShort] = Me.txtForShort
Me![FPinYin] = Me.txtPinYin
Me![FClientName] = Me.txtClientName
Me![FLinkman] = Me.txtLinkman
Me![FMobileNumber] = Me.txtMobileNumber
Me![FTelNumber] = Me.txtTelNumber
Me![FFaxNumber] = Me.txtFaxNumber
Me![FAddress] = Me.txtAddress
Me![FPostalcode] = Me.txtPostalcode
Me![FClientType] = Me.txtClientType
Me![FRemark] = Me.txtRemark
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 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|