I have a crosstab query as a source of a form and would like to nominate a column to sort on before it displays the form.
How do I do that?
Nominate a column in form to sort descending
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: Nominate a column in form to sort descending
I put the following code into the form's OnOpen Event:
Me.OrderByOn = True
me.OrderBy = "[query name got from record source].[value obtained from Label1.caption] DESC
It saves me having to display the form then choosing the column and choosing UpArrow in the ribbon
Me.OrderByOn = True
me.OrderBy = "[query name got from record source].[value obtained from Label1.caption] DESC
It saves me having to display the form then choosing the column and choosing UpArrow in the ribbon
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Nominate a column in form to sort descending
Another way would be to set the sort order in the crosstab query.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: Nominate a column in form to sort descending
How would you do that, on the value field? if so, how do you determine which column you are sorting?
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Nominate a column in form to sort descending
Ah, OK. If the columns of the crosstab query are fixed, you could create a new query based on the crosstab query, specify the sort order there, and use the new query as record source. Otherwise, setting the sort order in the On Open event is better, and it is probably easier in any case.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: Nominate a column in form to sort descending
Yes thanks, it is a dynamic query.
I have a OnClick of all the Label headings where I set it up to sort on a selected column.
I have a OnClick of all the Label headings where I set it up to sort on a selected column.