views:

375

answers:

2

I have a form where I specify information that is used by a subform in tabular view. The subform then displays entries for the item specified in the main form. Each entry has a date associated with it. I would like the entries to show up sorted by date such that the latest dates are at the bottom, and when you add an entry in the subform (supposedly with today's date) it appears where it needs to be. Of course, when you view a different item and then come back to this item, I would like the sort to put the new item in its appropriate, sorted spot (just in case the new item has an earlier date than any already in the database).

In a nutshell: How do I specify a sort criteria for a tabular form?

A: 

If you look in the property menu of the sub form, you will find the query that the form is based on. If in that query you select a 'Sort' order on the date column, that should be reflected on the form.

mavnn
the query for the form is not in the properties. also, there is an option called "Order By" and i put in Date, but it doesnt sort automatically. Once the form is open i can right click and say "Apply filter/sort..." and it will sort it by date, but it doesn't do it on opening the form like i would like it to.
Matt
I got it. I added a vba routine in the AfterUpdate spot. This is how it goes: Me.OrderBy = "Date" Me.OrderByOn = True thanks for the help
Matt
note: you might have to cycle OrderByOn false and then true to get it to take affect, especially if you've previously turned it on.
CodeSlave
If the underlying SQL SELECT is sorted appropriately, you shouldn't need to specify the ORDER BY properties, nor update them -- you only need to requery the form in the AfterUpdate event. And if the OrderBy is set and OrderBy is ON, you need only requery the form -- you don't need to toggle OrderBy ON.
David-W-Fenton
A: 

If you add records to the subform, you'll need to requery and refresh the form.

Jeff O
A refresh is redundant after a requery.
David-W-Fenton