Hi all,
Does anyone have any bright ideas for Access' tendency to add square
brackets when it parses queries, then tell you that the query syntax is
invalid. In my case, I'm trying to do a LEFT JOIN on a subquery, like so:
SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN (SELECT [Marker-Label] FROM targetMarkers
WHERE targetID = Forms!frmTargetDetails ) as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));
When I save the above query it gets parsed and saved as:
SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN [SELECT [Marker-Label] FROM targetMarkers
WHERE targetID = Forms!frmTargetDetails ]. as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));
or worse, it inserts the square brackets into the middle of the
subquery, like
[SELECT [Marker-Label] FROM targetMarkers WHERE targetID =
Forms]!frmTargetDetails )
If the query is saved as a QueryDef, Access seems to run the compiled
query and the misplaced text doesn't matter. However, if the original
SQL is used as the RowSource of a ComboBox, the combo box always given
an error OnEnter.
Is there a way to prevent Access from adding these erroneous square
brackets?
Thanks,
Eric