|
同事在Access里写了一个查询,
SQL View中显示的是下面的语句
---------------------------------------------------------------------------------------------------------------------------------------
SELECT [APJ LTM TRACKER].[MODEL CODE] AS Model, [APJ LTM TRACKER].SKU, [APJ LTM TRACKER].[SITE/ ODM] AS Site, [APJ LTM TRACKER].[EXT LT (ADDER)] AS [Ext Lead Time], "" AS [Std Lead Time], [APJ LTM TRACKER].[COUNTDOWN?] AS [Enable Countdown]
FROM [APJ LTM TRACKER]
WHERE ((([APJ LTM TRACKER].SKU) Is Not Null) AND (([APJ LTM TRACKER].Temp_capture)="Y") AND (([APJ LTM TRACKER].Status_internal)<>"Successful"));
-----------------------------------------------------------------------------------------------------------------------------------
这个语句能正常得到结果,然后我想在VBA中调用这个查询,
写的是
- Function test()
- Dim SQL As String
- SQL = "SELECT [APJ LTM TRACKER].[MODEL CODE] AS Model, [APJ LTM TRACKER].SKU, [APJ LTM TRACKER].[SITE/ ODM] AS Site, [APJ LTM TRACKER].[EXT LT (ADDER)] AS [Ext Lead Time], """" AS [Std Lead Time], [APJ LTM TRACKER].[COUNTDOWN?] AS [Enable Countdown] FROM [APJ LTM TRACKER] WHERE ((([APJ LTM TRACKER].SKU) Is Not Null) AND (([APJ LTM TRACKER].Temp_capture)=""Y"") AND (([APJ LTM TRACKER].Status_internal)<>""Successful""));"
- DoCmd.RunSQL SQL
- End Function
复制代码
就是把 " 替换成 "",然后头尾再加上 “
但是运行时报错
Error 2342
A RunSQL action requires an argument consistiong of an SQL statement.
是我的SQL = 后面那串哪里出错了吗?
|
|