我收到此错误
运行时错误3134
单击表单中的按钮即可将数据从表单插入到表中。
这是我试图执行的代码。
CurrentDb.Execute "INSERT INTO Main Sheet(Student Name, Pick Up Time, Home Address, Home City, School Hours, School Name, School Address, School City, Notes, School District, Parent Tel, Emergency Contact, Driver)" & _
"VALUES(" & Me.stdName & "','" & Me.pickUpTime & "','" & Me.homeAddress & "','" & Me.homeCity & "','" & Me.schoolHours & "','" & Me.schoolName & "','" & Me.schoolAddress & "','" & Me.schoolCity & "','" & Me.notes & "','" & Me.schoolDistrict & "','" & Me.parentTel & "','" & Me.emergencyContact & "','" & Me.driver & "')"
'refresh data in list on form
MainForm.Form.Requery
您需要用括号来表示带有空格的表和字段名称,以及用于数字和日期字段的格式正确的字符串表达式:
Dim Sql As String
Sql = "INSERT INTO [Main Sheet] ([Student Name], [Pick Up Time], [Home Address], [Home City], [School Hours], [School Name], [School Address], [School City], Notes, [School District], [Parent Tel], [Emergency Contact], Driver) " & _
"VALUES ('" & Me.stdName & "',#" & Format(Me.pickUpTime, "hh\:nn" & "#,'" & Me.homeAddress & "','" & Me.homeCity & "','" & Me.schoolHours & "','" & Me.schoolName & "','" & Me.schoolAddress & "','" & Me.schoolCity & "','" & Me.notes & "','" & Me.schoolDistrict & "','" & Me.parentTel & "','" & Me.emergencyContact & "','" & Me.driver & "')"
CurrentDb.Execute Sql