Please help me debug my sql query!
I keep on getting the error "incorrect syntax near keyword 'where'."
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 " & _
开发者_StackOverflow "(select preferenceid from GroupPreferences " & _
"where cabGroupId = " + Me.GroupId + " and override = 0)"
Assign the query to a string:
Dim myQuery as String
Set myQuery = "insert ..."
DoCmd.RunSql myQuery
Place a breakpoint on the last line, and copy/paste the query into MS Access query view. Try to run it and MS Access will tell you exactly what's wrong.
精彩评论