Can anybody let me know, why i receive a (Runtime error 3319: Syntax Error in union Query), when I run the following union Query :
sSQL = "SELECT 0 AS VoucherNo, #" & Format((txtFromDt), "dd/MMM/yy") & "# AS VoucherDate, " _
& "Vendors.VendorName, ""[Balance Brought Forward]"" AS Narration, 0 AS Debit, 0 AS Credit, " _
& "Sum([DR]-[CR]) AS Balance FROM Vouchers AS A INNER JOIN Vendors ON A.ClientID = Vendors.VendorID " _
& "Where (((A.VoucherDate) < #" & Format((txtFromDt), "dd/MMM/yy") & "#)) And ((A.ClientID) = " _
& """" & cmbLocName & """ ) GROUP BY """ & cmbLocName & """, Vendors.VendorName, " _
& """[Balance Brought Forward]"", 0, #" & Format((txtFromDt), "dd/MMM/yy") & "# " _
& "UNION SELECT A.VoucherNo, A.VoucherDate, Vendors.VendorName, A.Narration, A.DR AS Debit, " _
& "A.CR AS Credit, (Select Sum([DR]-[CR]) FROM Vouchers Where Vouchers.ClientID=A.ClientID " _
& "and VoucherNo<= A.VoucherNo ) AS Balance FROM Vouchers AS A INNER JOIN Vendors ON A.ClientID = " _
& "Vendors.VendorID WHERE (((A.VoucherDate) Between #" & Format((txtFromDt), "dd/MMM/yy") & "# " _
& "And #" & Format((txtToDt), "dd/MMM/yy") & "#)) AND ((A.ClientID)=""" & cmbLocName & """ )) " _
& "GROUP BY A.VoucherNo, A.VoucherDate, A.ClientID, Vendors.VendorName, A.Narration, A.DR, A.CR"