|
代码:
Option Compare Database
Private Sub Cmd_Enter_Click() '响应录入按钮的单击事件
On Error GoTo Err_Cmd_Enter_Click '错误处理
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Set conn = New ADODB.Connection
conn = currentprojct.Connection '连接当前数据库
conn.Open
Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockPessimistic
rst.Open " 零件", , , adCmdTable '连接表"零件"
With rst
.AddNew '插入新纪录
!零件编号 = Me.LJBHText '录入各字段信息
!零件名称 = Me.LJMCText
!规格 = Me.GGText
!质材 = Me.ZCText
!备注 = Me.BZText
.Update '提交操作
End With
MsgBox "恭喜你,产品型号已经成功加进数据库."
rst.Close '关闭连接
DoCmd.GoToRecord , , acNewRec
Exit_Cmd_Enter_Click:
Exit Sub
Err_Cmd_Enter_Click:
MsgBox Err.Description
Resume Exit_Cmd_Enter_Click
End Sub
Private Sub Cmd_exit_Click()
On Error GoTo Err_Cmd_exit_Click
DoCmd.Close
Exit_Cmd_exit_Click:
Exit Sub
Err_Cmd_exit_Click:
MsgBox Err.Description
Resume Exit_Cmd_exit_Click
End Sub
执行时提示需要对象
哪位帮我看看哪里出错了,在下感激不尽~~~ |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|