|
数据录入的例子的问题,看了“红尘如烟”的例子,有不懂得 请教下:http://www.office-cn.net/thread-62774-1-1.html
Me.Recordset.AddNew 这个是啥意思? 与 DoCmd.RunCommand acCmdSaveRecord(保存记录)有啥区别?
Private Sub Form_Current()事件不是很理解(不知道这个事件干啥) ctl.Value = Me.Recordset("F" & Mid(ctl.Name, 4))
这个干啥的?
请大家帮忙指点下 谢谢!- 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
- <FONT color=red>Me.Recordset.AddNew
- </FONT>
- 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.txtClientID, "") = "" Or _
- 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
- <FONT color=red>DoCmd.RunCommand acCmdSaveRecord
- </FONT>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
- <FONT color=red>Private Sub Form_Current()</FONT>
- On Error Resume Next
- Dim ctl As Control
- If Me.NewRecord Then
- Call cmdAdd_Click
- Else
- For Each ctl In Me.Controls
- <FONT color=red>ctl.Value = Me.Recordset("F" & Mid(ctl.Name, 4))</FONT>
- Next
- End If
复制代码 |
|