The query below works (=displays the account totals from the complete tables A and B)
If I replace the bold code below with this 'date filter'
"Sum(RCDetails19.DT_V) WHERE RCDetails19.Date<=Enddate AS TTrDTV, "&_
"Sum(RCDetails19.CT_W) WHERE RCDetails19.Date<=Enddate AS TTrCTW, "&_
I get the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Sum(RCDetails19.DT_V) WHERE RCDetails19.Date<=Enddate'.
Thanks for tips to solve this.
If I replace the bold code below with this 'date filter'
"Sum(RCDetails19.DT_V) WHERE RCDetails19.Date<=Enddate AS TTrDTV, "&_
"Sum(RCDetails19.CT_W) WHERE RCDetails19.Date<=Enddate AS TTrCTW, "&_
I get the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Sum(RCDetails19.DT_V) WHERE RCDetails19.Date<=Enddate'.
Thanks for tips to solve this.
Code:
Enddate=cdate(#2019/01/31#)
Dim Conn, rs1, sql1, rs2, sql2
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("_private/MY.mdb")
Set rs1 = Server.CreateObject("ADODB.Recordset")
Set rs2 = Server.CreateObject("ADODB.Recordset")
SQL1="SELECT Date, JBAccNR, Number, BInVKP, BUitAKP, ledenid, DT_V, CT_W FROM TableA "&_
"UNION ALL SELECT Date, JBAccNR, Number, BInVKP, BUitAKP, ledenid, DT_V, CT_W FROM TableB AS RCDetails19 ORDER BY Date ASC"
SQL2="SELECT ACC18.AccID, ACC18.AccDate, ACC18.AccNR, ACC18.AccNM, ACC18.varAccNr, "&_
[b]"Sum(RCDetails19.DT_V) AS TTrDTV, "&_
"Sum(RCDetails19.CT_W) AS TTrCTW, "&_
[/b]"Sum(RCDetails19.CT_W)-Sum(RCDetails19.DT_V) AS SaldoBVD "&_
"FROM ACC18 "&_
"LEFT JOIN RCDetails19 ON ACC18.AccNR=RCDetails19.JBAccNR "&_
"WHERE ACC18.AccNR is not null GROUP BY ACC18.AccID, ACC18.AccDate, ACC18.AccNR, ACC18.AccNM, ACC18.varAccNr ORDER BY ACC18.AccNR ASC"