我继续收到错误“关键字'附近的语法不正确',其中'。”
DoCmd.RunSQL "insert into userPreferences (userId, GroupId, preferenceId, properties, isDefault)" & _
"select " + Me.UserId + ", " + Me.GroupId + ", preferenceid, properties, 1 from preferences " & _
" where preferenceId not in " & _
"(select preferenceId from userPreferences where GroupId = " + Me.GroupId + _
" and userId = " + Me.UserId + _
" ) and preferenceid not in " & _
"(select preferenceid from GroupPreferences " & _
"where cabGroupId = " + Me.GroupId + " and override = 0)"
答案 0 :(得分:3)
将查询分配给字符串:
Dim myQuery as String
Set myQuery = "insert ..."
DoCmd.RunSql myQuery
在最后一行放置一个断点,然后将查询复制/粘贴到MS Access查询视图中。尝试运行它,MS Access会告诉你到底出了什么问题。