3.5.1 Single Reference Query

The following example shows a Query that references a single table, Tasks. The purpose of this query is to return all fields of the records from the Tasks table, in descending order of date due, that meet the following criteria:

  1. The task was scheduled to take more than 10 days.

  2. The task is due in the next 5 days.


 SELECT Tasks.*
 FROM Tasks
 WHERE (((Tasks.[EndDate])<5+Now()) AND ((Tasks.[EndDate])>10+Tasks.[StartDate]))
 ORDER BY Tasks.[EndDate] DESC;

Query AXL:

 <?xml version="1.0" encoding="utf-16" standalone="no" ?>
 <Query Name="MyQuery" xmlns="http://schemas.microsoft.com/office/accessservices/2009/04/application">
     <Reference Source="Tasks" />
     <Property Source="Tasks" All="true" />
     <Order Direction="Descending" Source="Tasks" Name="EndDate" />

The References element specifies the Tasks table is the data source for this query.

The Results element specifies that the query is returning all the fields from the Tasks table.

The Restriction element specifies an expression that selects only those records where the task is scheduled to last more than ten days and where the value of EndDate is within five days from now. The Now() function is specified in section

The Ordering element specifies that the results are sorted in descending order based on the EndDate field.