开发者

Please help me debug my sql query!

开发者 https://www.devze.com 2023-01-21 17:16 出处:网络
I keep on getting the error \"incorrect syntax near keyword \'where\'.\" DoCmd.RunSQL \"insert into userPreferences (userId, GroupId, preferenceId, properties, isDefault)\" & _

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消