I ran into a strange behaviour within Access. I basically have two predefined queries within my VBA-Project that are needed in different parts of the programm which are working fine.
Now I need a query which returns both result-sets as one. So my go to Solution was to create a new query combining the other two queries. Just like:
SELECT * FROM query1
UNION
SELECT * FROM query2;
Both queries have the same layout in their result. But if the result of query1 is empty and query2 has some records in its result I receive an empty result from the code above. The other way (empty result for query2 - several results for query1) it is delivering me a complete result.
I also tested the above code with the two queries switched. But the behaviour was the same. Same thing with UNION ALL.
What could be the issue here?
Edit: So, I did some further testing. The reason seems to be within query2. It can't even be unionized with itself. So if i try:
SELECT * FROM query2
UNION ALL
SELECT * FROM query2;
I again get an empty set. Same when i just use one field in the SELECT-part.
Edit2: OK it gets better. The Dataset is empty but within the table-view of the query result i have all the data within the filters of the columns. But if I do a Count(rowname) I get a 0 in return.
*. - SunKnight0query1andquery2with their full SQL code? That may give you a meaningful error. - SunKnight0