sorting by control value

R

Russ

Is there a way to sort a form's reports by the value found in a
specified field or control? Normally the form will sort according to
record number, and that is just not going to work as the records were
entered not in the order I would like to have them viewed. The Order
By in the form's property window appears to do nothing when I enter
the control's name in it.
 
F

fredg

Is there a way to sort a form's reports by the value found in a
specified field or control? Normally the form will sort according to
record number, and that is just not going to work as the records were
entered not in the order I would like to have them viewed. The Order
By in the form's property window appears to do nothing when I enter
the control's name in it.

When you manually add a control name to the OrderBy property NOTHING
happens unless you also tell Access to apply the sort.
You apply the sort when you right click on the form (in Form View) and
select "Apply Filter/Sort".
Conversely, to go back to the previous sort, you would right-click on
the form and select "Remove Filter/Sort"

Anything wrong with you simply selecting the control and clicking on
the Sort A-Z or Z-A toolbutton?
 
R

Russ

When you manually add a control name to the OrderBy property NOTHING
happens unless you also tell Access to apply the sort.
You apply the sort when you right click on the form (in Form View) and
select "Apply Filter/Sort".
Conversely, to go back to the previous sort, you would right-click on
the form and select "Remove Filter/Sort"

Anything wrong with you simply selecting the control and clicking on
the Sort A-Z or Z-A toolbutton?


Thanks. I was not aware of having the user tell Access to apply the
sort. I wondered why that never worked for me.

However, I really want the form to display the records sorted by that
particular control when it's initially opened without the user
applying the sort. Any way to do that?
 
R

Russ

Russ,

You could try placing the below in the On_Open event of the form...

Me.OrderBy = "YourFieldNameHere"
Me.OrderByOn = True


Thanks Gina I think that may work out fine. I tried the OrderBy code
yesterday, but was unable to figure out the syntax with my limited
knowledge of VBA.
 
J

John W. Vinson

Is there a way to sort a form's reports by the value found in a
specified field or control? Normally the form will sort according to
record number, and that is just not going to work as the records were
entered not in the order I would like to have them viewed. The Order
By in the form's property window appears to do nothing when I enter
the control's name in it.

Just note that you can base the Form on a Query sorted appropriately, and it
will use that order with no code at all. The form's OrderBy property can be
used to override this sort if you choose.
 

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