开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜