Subform sort order problem

  • Thread starter Anthony Spatuzzi
  • Start date
A

Anthony Spatuzzi

I have a form/subform. They are linked on the field 'cnum'. The fields in
the table 'Received' which is what the subform is bound to are:

Cnum
Ldate
Lbs
Furniture
Clothes
Council

The 'OrderBy' = received.ldate DESC
and 'OrderByOnLoad' = yes

However, when subform opens the records are sorted in ascending order.

To check this I put the following into the 'Current' event of the form:

Debug.Print Me.OrderBy, Me.OrderByOn, Me.OrderByOnLoad

The results of this are:

ldate DESC False True
ldate DESC False True
ldate DESC False True
ldate DESC False True


In order for it to sort in the descending order, I put the following into
the 'Current' event of the form:
Me.OrderByOn = True

which yields:

ldate DESC False True
ldate DESC True True
ldate DESC True True
ldate DESC True True
ldate DESC True True

One point which may be of importance is that I took this form and most
every object from a corrupted dB using the technique outlined by Allen
Browne. I also was fairly certain that I did not pull the corrupting form
into the new dB.

Thanks
 
A

Anthony Spatuzzi

Instead of applying the sort to the form, why not create a sorted
recordsource for the form, that is, create a query as the record source for
the subform and sort it there.

I must have misstated the question. In code I can get it to sort correctly
by setting the 'Me.OrderByOn = true' in the oncurrent event of the form.
However, this should not be necessary as I have used this form/subform
combination before and it behaves as I desire ie; if I want an ascending
sort I get an ascending sort and if I want a descending sort I get a
descending sort via the form's properties.

The output of the debug.print shows that the 'orderby' property is false
when it should be true.

Thanks
 

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