sorting in subform

G

Guest

i have a subform with three columns .... date, service, price.

i have set the subform "order by" field to date, however, the subform still
shows the data in the data-entry order.

is there something else i'm overlooking?
 
A

Allen Browne

Try setting the subform's OrderByOn property in its Open event:
Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = "[date]"
Me.OrderByOn = True
End Sub

If you really have a field called "date" that could be the problem. That's a
reserved word in SQL (for the field type) and in VBA (for the system date.)
Access is likely to misunderstand the reference. For example, if it sorted
all records by today's date (not the value of the Date field), they would
all be equal (so unsorted.) Rename the field to ServiceDate or something,
and then change the Name and ControlSource of the field on your form.

Another option is to create a query, and use the Sorting row in query design
to specify how you want it sorted. Then open your subform in design view,
and change its Record Source property to the query.
 

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

Top