Sorting data in Foreign key drop down lightswitch

2019-08-10 16:43发布

问题:

I having country as Foreign key in one of the table.

So it is shown as drop down(is it a drop down? see image above)

My question is how can I specify the data in the drop down/input is to be in sorted order?

回答1:

As Crezzer mentioned, the foreign key drop down details pickers are intrinsically sorted by entry order (with the earliest records appearing at the top).

However, if you'd like to change this sort order, you simply need to add a sorted query against your countries table. This can be done by either clicking the 'Query' button at the top of the table designer screen or by right mouse clicking on the Countries table in the 'Solution Explorer' and choosing the 'Add Query' option.

You can then add a query along the following lines (specifying the desired sort by fields):

Then, on the screen featuring the countries drop down details picker, you would select the 'Add Data Item...' button (at the top of the screen designer) and introduce the sorted query onto the screen as follows:

You can then select to use this sorted query for the drop down details picker by highlighting the control in the screen designer and changing the 'Choices' property from 'Auto' to the added query as follows (the required property selection is highlighted in purple):