Hello Phan Hoàng Anh,
this is a common mistake. You have made the same description for the document and for the tabular section of this document (please see screenshot 1). Because of this, when building a query to the data, the system "doesn't understand" where to get the data from.
By the way, it's very easy to check the correctness of the query if you try to open the "Query Wizard". If the query contains a syntax error, the Wizard will not open, but an error will appear (screenshots 2 and 3).
In your case, it's enough to change the name of the virtual table "Expense" to "ExpenseRef" in the query, for example. (Screen 4 and 5)
And the query text will look like this:
Code |
---|
Query.Text = "SELECT
| ExpenseRef.Account AS Account,
| ExpenseRef.Date AS Date,
| ExpenseRef.Shop AS Shop,
| ExpenseRef.Expense.(
| Amount AS Amount
| ) AS Expense
|FROM
| Document.Expense AS ExpenseRef
|WHERE
| ExpenseRef.Ref IN(&Ref)";
|
But in general, it is better to avoid a situation when the document itself and its tabular section have the same description.