Hey guys i'm trying to write sql query in vba module and i'm getting all the time a syntax error 3075.
What is wrong with my code?
What is wrong with my code?
Code:
Function rs()
On Error Resume Next
Dim MM As String
Dim rstB As Recordset
Dim Par1 As String
Par1 = 1360
Dim Par2 As String
Par2 = "dbKA"
Set rstB = CurrentDb.OpenRecordset("SELECT tSale.KodParty" & _
", tSale.GoodsID" & _
", tSale.KodWork" & _
", tSale.ActualMU" & _
", tSale.NumberUnits" & _
", tSale.CostOut" & _
", tSale.Summ" & _
" (((FROM [tMov_ClientInvoiceDetails] AS tSale" & _
" INNER JOIN [tMov_Parties] AS tParty ON tSale.KodParty = tParty.KodParty)" & _
" INNER JOIN [tPrd_Goods] AS PL ON tSale.GoodsID = PL.GoodsID)" & _
" INNER JOIN [tPrd_GoodsData] AS PN ON tSale.GoodsID = PN.GoodsID)" & _
" INNER JOIN [WB_units_list] AS RS ON tSale.ActualMU = RS.OurID)" & _
" Where (tMov_Parties.KodParty = " & Par2 & ") And (tPrd_GoodsData.langID = " & Par2 & ")")
Do While Not rstB.EOF
MM = rstB("KodWork")
Debug.Print MM
rstB.MoveNext
Loop
End Function