I have a particular query that requires me to INNER JOIN when a records EXIST in a a query but not JOIN if they don't. I was wondering if this was possible by writing it in SQL or if I was forced to write it in VBA. If VBA is required how would I pull the resulting record set into excel. I know how to do this by just calling the query, but not if the query is run from an internal module in access.
Code should look something like:
IF condition
SELECT *
FROM table1
INNER JOIN table2
ON table1.a = table2.a
Else
SELECT *
FROM table1
Thank you in advance for assistance.