Accessing Data

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Queries enable you to ask questions about the data in the Microsoft Dynamics AX database and retrieve information. There are two ways to create queries:

No matter which method that you use to create a query, the query can include a sorting order to sort the information that is returned. It can also include a range to filter the information that is returned based on your criteria.

A query can return data from multiple data sources. For more information, see How to: Add Multiple Data Sources to a Query.

You can create queries for forms and reports. For more information, see How to: Coordinate Two Forms by Overriding an Event Method.


When you create a query with X++, you can add paging support to that query. Paging retrieves the results of a query as a collection of one or more data subsets known as pages. The QueryRun class supports the following types of paging:

  • Position based paging divides the query result into pages and enables you to display the data records represented by a specified page.

  • Value based paging uses a page to represent the data records that are currently displayed in a data grid. Use value based paging when you want an update to a data grid to automatically redisplay the same set of data records.

To enable paging, use the enablePositionPaging and enableValueBasedPaging methods of the QueryRun class. To use paging with a query, the query cannot have a disabled data source. Also, the value of the FirstOnly property of the data source must be set to No.

See also

Customizing the Query Form

Query Properties

Query System Classes

Using Expressions in Query Ranges

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.