Order By syntax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When in design view, there is a setting called Order By.

I want my form to order by the following fields, ascending:
DayOfWeek
DueDate

I can't seem to get the syntax right. I tried:
DayOfWeek, DueDate
"DayOfWeek, DueDate"
DayOfWeek; DueDate
"DayOfWeek; DueDate"
DayOfWeek: DueDate
"DayOfWeek: DueDate"
[DayOfWeek], [DueDate]
"[DayOfWeek], [DueDate]"
[DayOfWeek]; [DueDate]
"[DayOfWeek]; [DueDate]"
[DayOfWeek]: [DueDate]
"[DayOfWeek]: [DueDate]"

I've even tried adding the table name and it didn't work
(duedates.DayOfWeek: duedates.DueDate).

What am I missing?
 
When in design view, there is a setting called Order By.

I want my form to order by the following fields, ascending:
DayOfWeek
DueDate

I can't seem to get the syntax right. I tried:
DayOfWeek, DueDate
"DayOfWeek, DueDate"
DayOfWeek; DueDate
"DayOfWeek; DueDate"
DayOfWeek: DueDate
"DayOfWeek: DueDate"
[DayOfWeek], [DueDate]
"[DayOfWeek], [DueDate]"
[DayOfWeek]; [DueDate]
"[DayOfWeek]; [DueDate]"
[DayOfWeek]: [DueDate]
"[DayOfWeek]: [DueDate]"

I've even tried adding the table name and it didn't work
(duedates.DayOfWeek: duedates.DueDate).

What am I missing?

The proper syntax for more than 1 field would be:
TableName.FieldName1, TableName.FieldName2

Nothing will happen until you right-click on the form and select Apply
Filter/Sort.

A better method would be th use a query as the record source for the
form and do the sorting directly in the query.
 
Read Access Help for the OrderBy property. It isn't the syntax that is the
problem, you will need to put some code in the Open event of your form to do
the sorting action as described in Help
 
I had some other setting blocking the sort ability.

Once I unlocked and enabled the two fields, it took the following:
DueDates.DayOfWeek, DueDates.DueDate

I saved the sort, then disabled and locked the two fields and it took. As
long as I had both fields locked and disabled, it wouldn't take the sort,
even when I entered it in the correct syntax.

....weird.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top