Sorting Subforms

P

PSI-Access

Hi,

I've looked through the past questions but can't seem to take any of the
knowledge from them and apply it to my situation. I must be missing
something. I have a form with a subform that are linked on a date field in
the main form. I am having trouble in that ever time a user sorts or filters
the subform, they are forgetting that they have done that and when they
return to the form, it is not necessarily showing them the information in the
proper order or is leaving out records because of a filter. What I would like
to do is somehow write code to reset the subform's sort order and remove any
applied filters when the user opens the form or changes the date in the text
box which links the form and subform together. I have tried the OrderBy but
it's giving me grief in how I am applying it.

Any advice would be greatly appreciated...
 
A

Allen Browne

Put some code into the Open event of the subform that sets its RecordSource
and guarantees the FilterOn and OrderByOn properties are off:

Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "SELECT Table1.* FROM Table1 ORDER BY Table1.MyField;"
Me.FilterOn = False
Me.OrderByOn = False
End Sub
 

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