在运行时错误3129中需要帮助,并使用SELECT语句
代码在下面。在第一和最后一行中遇到错误。我认为第二行上有一个额外的(
> )),但这不会解释最后一行的错误。
DoCmd.RunSQL (sqlStr)
strSQL = "SELECT fct_monitoring.MeasureID FROM fct_monitoring WHERE MeasureID IN (" & _
Chr(34) & "CAUTI_Rate_All" & Chr(34) & "," & _
Chr(34) & "CDI_LabID" & Chr(34) & "," & _
Chr(34) & "CLABSI_Rate_All" & Chr(34) & "," & _
Chr(34) & "Falls_Injury" & Chr(34) & "," & _
Chr(34) & "READ-1" & Chr(34) & ")" & _
Chr(34) & "CAUTI_SIR_All" & Chr(34) & "," & _
Chr(34) & "CDI_SIR" & Chr(34) & "," & _
Chr(34) & "CLABSI_SIR_All" & Chr(34) & "," & _
" GROUP BY fct_monitoring.MeasureID;"
Set msrRst = dbs.OpenRecordset(strSQL)
Code is below. Getting errors on first and last lines. I think there is an extra (
or else missing )
on 2nd line but that wouldn't explain the error on the last line.
DoCmd.RunSQL (sqlStr)
strSQL = "SELECT fct_monitoring.MeasureID FROM fct_monitoring WHERE MeasureID IN (" & _
Chr(34) & "CAUTI_Rate_All" & Chr(34) & "," & _
Chr(34) & "CDI_LabID" & Chr(34) & "," & _
Chr(34) & "CLABSI_Rate_All" & Chr(34) & "," & _
Chr(34) & "Falls_Injury" & Chr(34) & "," & _
Chr(34) & "READ-1" & Chr(34) & ")" & _
Chr(34) & "CAUTI_SIR_All" & Chr(34) & "," & _
Chr(34) & "CDI_SIR" & Chr(34) & "," & _
Chr(34) & "CLABSI_SIR_All" & Chr(34) & "," & _
" GROUP BY fct_monitoring.MeasureID;"
Set msrRst = dbs.OpenRecordset(strSQL)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您真的只想打印出SQL语句 - 试图解决所有这些串联是错误的错误。
SQL语句,您可以更好地阅读 - 如果需要
通过该调试输出,您可以查看一些使某些更有意义的东西(应该是 这种更好的格式,我想我可以看到,大概是在阅读1之后,您有一个括号,应该是引用,而在clabsi_sir_all之后,您有一个逗号,您应该有一个括号(看起来像是有人决定移动一条线)) 。
You really want to just print out the sql statement - it is too error prone to try to work out all these concatenations.
With that debug output you can look at something that makes a bit more sense (it should be a sql statement you can read better - if you want, you can even paste it into a query in sql design view and run it.
Although actually in this better format, I think I can see that probably after READ-1 you have a parenthesis that should be a quote, and after CLABSI_SIR_All you have a comma where you should have a parenthesis (this looks like someone decided to move a line around).
从发布的代码准确地确定您想做什么,但这应该是接近的:
不需要所有这些
chr(34)
,因为您可以使用单价。Not possible to be sure from your posted code exactly what you want to do, but this should maybe be close:
No need for all that
Chr(34)
since you can use single-quotes.