将以下拷贝后替换你原先的代码编程就要细心再细心)
Private Sub Command16_Click()
On Error GoTo Err_cmdAdd_Click
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from 项目明细"
rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'MsgBox rs.RecordCount
If IsNull(Me.项目编号) Then
MsgBox ("请输入项目编号!")
Me.项目编号.SetFocus
ElseIf IsNull(Me.生产数量) Then
MsgBox ("请输入生产数量!")
ElseIf IsNull(Me.预计产量) Then
MsgBox ("请输入预计产量!")
ElseIf IsNull(Me.原料成本) Then
MsgBox ("请输入原料成本!")
ElseIf IsNull(Me.制作成本) Then
MsgBox ("请输入制作成本!")
ElseIf IsNull(Me.人工成本) Then
MsgBox ("请输入人工成本!")
ElseIf IsNull(Me.毛利润) Then
MsgBox ("请输入毛利润!")
Else
With rs