Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort data on a subform 2

Status
Not open for further replies.

TommyTea

Programmer
Nov 7, 2002
43
US
Hello. I need to sort data displayed on a sub-form by running code from a command button on the main form. I tried forms("frmMain.form.frmSubForm").OrderBy = fieldname and every permutation that I could think of. Any wisdom out there? Thanks.
 
Basically you need to walk the following property structure:
Code:
Forms!frmMainForm!ctlSUBFORM_CONTROL_NAME_HERE.Form.OrderBy

So figure out what the name of the subform *control* on the main form is, then use that name to access the subform itself. The name of the subform itself is in this case irrelevant.
 
DoCmd.GoToControl "YourSubformName"
DoCmd.GoToControl "YourFieldName"
DoCmd.RunCommand acCmdSortDescending
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top