我有一个表格设置,我可以在访问数据添加到表。我有空间的数据输入,然后“添加”按钮来添加数据。但是,每当我运行它时,我得到的错误:运行时错误424对象必需。访问代码错误
Private Sub cmdAdd_Click()
'when we click on button Add there are two options
'1. For insert
'2. For Update
If Me.txt_code.Tag & "" = "" Then
'this is for insert new
'add data to table
CurrentDb.Execute = "INSERT INTO KWTable(KW, Source, Code) " & _
" VALUES(" & Me.text_key & ",'" & Me.txt_code & "','" & _
Me.combo_source & "')"
Else
'otherwise (Tag of txtID store the id of student to be modified)
CurrentDb.Execute "UPDATE KWTable " & _
" SET KW=" & Me.text_key & _
", Code='" & Me.txt_code & "'" & _
", Source='" & Me.combo_source & "'" & _
" WHERE KW=" & Me.text_key
End If
'clear form
cmdClear_Click
'refresh data in list on form
TableSub.Form.Requery
End Sub
被CodeStorage甚至定义? – basdwarf
你能多给点信息吗?你用来添加数据的代码是什么? CodeStorage被定义为字符串吗? – Gutanoth