我在下面有这个代码,当我尝试运行它时,它会在代码的最后一行显示错误消息“无效操作”。所有语法看起来都正确。我究竟做错了什么?
PCycle = PreviousCycle(CurrentCycle(Me.cobMainType.Value), mainType(Me.cobMainType.Value))
SQL = "INSERT INTO tblVehMainType (MainID, PartID, VehTypeID)"
SQL = SQL & " Select " & Me.cobMainType & ", PartID, VehTypeID"
SQL = SQL & " From tblVehMainType "
SQL = SQL & " WHERE vehTypeID = " & Me.cobVehType & " AND MainID = " & PCycle & ";"
Set rst = CurrentDb.OpenRecordset(SQL)
答案 0 :(得分:2)
INSERT
语句不会返回记录集,因此您不应使用.OpenRecordset
来运行它。您应该使用.Execute
代替。