Dim Db As DAO.Database Dim Rs As DAO.Recordset Set Db = CurrentDb() Set Rs = Db.OpenRecordset("学生信息", dbOpenDynaset) '新增记录 Rs.AddNew Rs!ID = Me!ID Rs!姓名 = Me!姓名 Rs!性别 = Me!性别 Rs!出生日期 = Me!出生日期 If IsNull(ID) Then MsgBox "没输入主键" Else '更新记录 Rs.Update MsgBox "新增成功" End If