请问vba可以调用视图吗?
我用的VBA写的
strsql = "SELECT W.cWhCode as 仓库号, W.cWhName as 仓库名称, I.cInvCode as 存货编码, I.cInvName as 存货名称, I.cInvCCode as 存货大类编码 , IC.cInvCName as 存货大类名称," _
& "(fInQuantity) AS 现存量,(fTransInQuantity) AS 调拔待入数量,(ISNULL(fInQuantity,0) + ISNULL(fTransInQuantity,0)) AS 到货在检," _
& "(fOutQuantity) AS 待发货量, (fTransOutQuantity) AS 调拔待发数量, (ISNULL(fOutQuantity,0) + ISNULL(fTransOutQuantity,0)) AS 预计出库数量 , " _
& "(CASE WHEN bInvBatch=1 THEN CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iQuantity,0)- IsNull(fStopQuantity,0) END + ISNULL(fInQuantity,0) + ISNULL(fTransInQuantity,0) - ISNULL(fOutQuantity,0) - " _
& "ISNULL(fTransOutQuantity,0) ELSE CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iQuantity,0)- IsNull(fStopQuantity,0) END END) AS 可用量" _
& "FROM v_ST_currentstockForReport CS inner join dbo.Inventory I ON I.cInvCode = CS.cInvCode " _
& "left join dbo.InventoryClass IC ON IC.cInvCCode = I.cInvCCode LEFT OUTER JOIN dbo.ComputationUnit CU_G ON " _
& "I.cSTComUnitCode =CU_G.cComUnitCode LEFT OUTER JOIN dbo.ComputationUnit CU_A ON I.cAssComUnitCode = CU_A.cComunitCode " _
& "LEFT OUTER JOIN dbo.ComputationUnit CU_M ON I.cComUnitCode = CU_M.cComunitCode LEFT OUTER JOIN dbo.Warehouse W ON CS.cWhCode = W.cWhCode " _
& "left join vendor v1 on v1.cvencode = cs.cvmivencode left join v_aa_enum E1 on E1.enumcode = ISNULL(cs.iExpiratDateCalcu,0) and E1.enumtype=N'SCM.ExpiratDateCalcu' " _
& "LEFT OUTER JOIN dbo.v_aa_enum E with (nolock) on E.enumcode=convert(nchar,CS.cMassUnit) and E.enumType=N'ST.MassUnit'"
提示v_ST_currentstockForReport附近有错误,可我就是看不出来。
是不是不可以引用视图啊? vba
[解决办法]
FROM前面缺少空格