The following SQL in VBA ADO gives the \'syntax error in From clause\' error.
Sub RunSQL2()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Consider using a correlated count aggregate query for row number in place of the window function as this subquery should by compliant in Jet/ACE SQL:
SELECT v.child_index, v.child_level, v.parent_level, u.child_index, v.parent_index
FROM
(SELECT s.*
FROM
(SELECT t.*, (SELECT count(*) FROM [mydata$A1:C30020] sub
WHERE sub.child_index <= t.child_index
AND sub.child_level = t.child_level) as [rownum]
FROM [mydata$A1:C30020] t
) s
WHERE [rownum] = 1
) u
INNER JOIN
(SELECT t2.*, 1 as [rownum]
FROM [mydata$A1:C30020] t2
) v
ON (v.parent_level = u.child_level) AND (v.[rownum] = u.[rownum])
UNION
SELECT w.child_index, w.child_level, w.parent_level, w.child_index, w.parent_index
FROM [mydata$A1:C30020] w
WHERE w.child_index = 1
ORDER BY v.child_index;