我有一个访问表单。我正在使用VBA将值输入表中。
问题:
"Too few parameters; Expected 1;"
- 即使表格列名称与插入声明中的内容相符,我也会收到此错误。
Private Sub Command125_Click()
Dim dbsCurrent As Database
Set dbsCurrent = CurrentDb
'add data to table production_date, reason, downtime_minutes, comment , Me.Text126, Me.Text121, Me.Text123, Me.Text128
dbsCurrent.Execute " INSERT INTO tbl_Downtime " _
& "(job) VALUES " _
& "(dbsCurrent.Me.Text116);"
End Sub
结束目标:
首先,我想修复此错误。但我还需要能够根据ID更新行(在表中自动编号)。如果用户知道行的ID,我如何允许用户更新行?
答案 0 :(得分:0)
问题似乎是您在VBA引用周围加上Text116的引号。我假设"工作"是一个字符串。请尝试以下方法:
Private Sub Command125_Click()
Dim dbsCurrent As Database
Set dbsCurrent = CurrentDb
'add data to table production_date, reason, downtime_minutes, comment , Me.Text126, Me.Text121, Me.Text123, Me.Text128
dbsCurrent.Execute " INSERT INTO tbl_Downtime " _
& "('job') VALUES " _
& "('" & dbsCurrent.Text116 & "');"
End Sub