[AccessD] Storing and reapplying a sort

Bob Gajewski rbgajewski at roadrunner.com
Tue Jun 21 17:41:09 CDT 2011


William

Do you have the default sort (Order By) defined in the RecordSource of the
subform?

Example: SELECT tblMembersResponses.ResponseID,
tblMembersResponses.IncidentID, tblMembersResponses.MemberNumber,
tblMembersResponses.LastUpdated FROM (tblMembers INNER JOIN
tblMembersResponses ON
tblMembers.MemberNumber=tblMembersResponses.MemberNumber) INNER JOIN
tblIncidents ON tblMembersResponses.IncidentID=tblIncidents.IncidentID ORDER
BY tblMembersResponses.ResponseID;

If it's a static sort, that's the easiest way ...

If you need a dynamic sort, you can define the criteria into a variable
(strSortOrder in example below):

Dim frm As Form
Set frm = Forms(sfrmYourSubFormName)
    frm.OrderByOn = True
    frm.OrderBy = strSortOrder

Regards,
Bob Gajewski


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William Benson
(VBACreations.Com)
Sent: Tuesday, June 21, 2011 12:16 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Storing and reapplying a sort

I have a subform in datasheet view.

When sorted, and I refresh the datasource, I am losing the sort.

What property can I read to find out the currently applied sort?

And can someone type me a line of code that will apply a sort?

Thanks

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list