The way this is written is confusing WHERE with INNER JOIN. They are more mutually exclusive, not meant to be combined together.
Also, you need an alias (AS) for your XyzQuery to use it.
This should be debugged as SQL first, and VBA second.
Right now it is reading as:
Code:
SELECT Abcfield1, Abcfield2
FROM Table_abc
WHERE Abc_field1 = Textboxfield1.Value
INNER JOIN
SELECT Xyzfield1, Xyzfield2
FROM Table_xyz
ON Table_abc.Abcfield1 = Xyzquery.Xyz_field1
ORDER BY Abc_field1 ASC, Abc_field2 DESC
It would be a valid SQL query as:
Code:
SELECT Abcfield1, Abcfield2
FROM Table_abc
INNER JOIN
(SELECT Xyzfield1, Xyzfield2
FROM Table_xyz) AS XyzQuery
ON Table_abc.Abcfield1 = Xyzquery.Xyz_field1
WHERE Abc_field1 = Textboxfield1.Value
ORDER BY Abc_field1 ASC, Abc_field2 DESC