Hi
I have two queries and I'd like to join/merge the results of these two queries. I have tried a simple case as follows and I have no problems:
This code returns all records where name is equal to '940212' and concatenates right after those with name = '230104'
In reality my goal is to concatenate two queries that are a bit more complicated:
If I use these two queries with the UNION Statement, I receive Run-Time Error 3021: No Current Record.
If I run them separately they work fine.
Could someone suggest me what is creating the Error 3021?
Thanks
I have two queries and I'd like to join/merge the results of these two queries. I have tried a simple case as follows and I have no problems:
Code:
strSQL1 = "select name from table Where name='940212'"
strSQL2 = "select name from table Where name='230104'"
strSQL1 = strSQL1 & " UNION ALL " & strSQL2
Debug.Print strSQL1
Set qdf = db.CreateQueryDef("Query_output", strSQL1)
DoCmd.OpenQuery "Query_output"
This code returns all records where name is equal to '940212' and concatenates right after those with name = '230104'
In reality my goal is to concatenate two queries that are a bit more complicated:
Code:
strSQL1 = "SELECT table.name, Year(table.Month) AS YEAR, round(table.Quarter,2) AS Performance " & _
" FROM table WHERE (Month(table.Month) IN (12))"
strSQL2 = " SELECT table.name, Year(table.Month) AS YEAR, round(table.Quarter,2) AS Performance " & _
" FROM table INNER JOIN (SELECT table.name, MAX(table.month) AS MaxOfReportingDate FROM table GROUP BY name) " & _
" AS a ON table.name = a.name AND table.month = a.MaxOfReportingDate ORDER BY table.month DESC"
If I use these two queries with the UNION Statement, I receive Run-Time Error 3021: No Current Record.
If I run them separately they work fine.
Could someone suggest me what is creating the Error 3021?
Thanks
