2016-12-20 159 views
0

在VBA中有一個錯誤,這個查詢作爲一個交叉表正常運行,但是當我嘗試切換VBA時,在TRANSFORM語句中引發了一個語法錯誤有人可以幫我嗎?謝謝。TRANSFORM語句中的VBA-語法錯誤

 "TRANSFORM Str(Count([Prijava].[id]))AS O, Str(Count([Prijava].[datumSmrti])) AS U" & _ 
    "SELECT MKB10.id, IIf([pol].[id]=1,'M','Ž') AS pol, MKB10.NazivLatinski" & _ 
    "FROM Pol INNER JOIN ((Opstina INNER JOIN Pacijent ON Opstina.id = Pacijent.opstinaID) INNER JOIN (MKB10 INNER JOIN Prijava ON MKB10.id = Prijava.mkb10ID) ON Pacijent.id = Prijava.pacijentID) ON Pol.id = Pacijent.polID" & _ 
    "GROUP BY MKB10.id, IIf([pol].[id]=1,'M','Ž'), MKB10.NazivLatinski" & _ 
    "ORDER BY MKB10.id" & _ 
    "PIVOT starosnoDoba2([starost]) In ('<1','1','2','3','4','5','6','7-9','10-14','15-19','20-29','30-39','40-49','50-59','60-69','70>')" 

回答

1

我想出答案是愚蠢的,一切都很好,當然,它的工作原理,但一有幾件事需要糾正,哪裏有逗號應該是&「」「」「&並且由於它後面跟着一個字符串繼續& _在那之前應該像pollID」 「這樣,看起來像這樣`

"TRANSFORM Str(Count([Prijava].[id]))&"" ""& Str(Count([Prijava].[datumSmrti])) " & _ 
"SELECT MKB10.id &"" ""& IIf([pol].[id]=1,'M','Ž') &"" ""& MKB10.NazivLatinski " & _ 
"FROM Pol INNER JOIN ((Opstina INNER JOIN Pacijent ON Opstina.id = Pacijent.opstinaID) INNER JOIN (MKB10 INNER JOIN Prijava ON MKB10.id = Prijava.mkb10ID) ON Pacijent.id = Prijava.pacijentID) ON Pol.id = Pacijent.polID " & _ 
"GROUP BY MKB10.id, IIf([pol].[id]=1,'M','Ž'), MKB10.NazivLatinski " & _ 
"ORDER BY MKB10.id " & _ 
"PIVOT starosnoDoba2([starost]) In ('<1','1','2','3','4','5','6','7-9','10-14','15-19','20-29','30-39','40-49','50-59','60-69','70>') " 
2
"TRANSFORM Str(Count([Prijava].[id]))AS O, Str(Count([Prijava].[datumSmrti])) AS U " & _ 
    "SELECT MKB10.id, IIf([pol].[id]=1,'M','Ž') AS pol, MKB10.NazivLatinski " & _ 
    "FROM Pol INNER JOIN ((Opstina INNER JOIN Pacijent ON Opstina.id = Pacijent.opstinaID) INNER JOIN (MKB10 INNER JOIN Prijava ON MKB10.id = Prijava.mkb10ID) ON Pacijent.id = Prijava.pacijentID) ON Pol.id = Pacijent.polID " & _ 
    "GROUP BY MKB10.id, IIf([pol].[id]=1,'M','Ž'), MKB10.NazivLatinski " & _ 
    "ORDER BY MKB10.id " & _ 
    "PIVOT starosnoDoba2([starost]) In ('<1','1','2','3','4','5','6','7-9','10-14','15-19','20-29','30-39','40-49','50-59','60-69','70>') " 

您將字符串連接時需要的空間,否則你的文字一起運行......此致正在讀"TRANSFORM..... AS USELECT..."

+0

是的戴夫我看到了,愚蠢的我:) –