Selasa, 04 September 2012

RE: [MS_AccessPros] Updated: Sorting a subform from main form

 

I would probably use a combo box with a row source of a table of all possible sort orders.
tblSortOrders
=================
sorSOrID autonumber primary key
sorFormName a form name so you can use this for any form
sorTitle text you want to display to the users
sorExpression value that you can set Order By property of the form/subform

The combo box Row Source would be something like:

SELECT sorTitle, sorExpression
FROM tblSortOrders
WHERE sorFormName = "YourFormName"
ORDER BY sorTitle;

Then use code in the after update event of the combo box to something like:

If Not IsNull(Me.cboSortOrder) Then
Me.[YourSubformControlName].Form.OrderBy = Me.cboSortOrder.Column(1)
Me.[YourSubformControlName].Form.OrderByOn = True
Else
Me.[YourSubformControlName].Form.OrderByOn = False
End If

Caution, this is air code.

Duane Hookom
MS Access MVP


> To: MS_Access_Professionals@yahoogroups.com
> From: tsherven@mcd.net
> Date: Tue, 4 Sep 2012 10:28:43 -0500
> Subject: [MS_AccessPros] Updated: Sorting a subform from main form
>
> Sorry...my subject meant to say "Sorting a subform from a main form".
>
>
>
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Troy
> Sherven
> Sent: Tuesday, September 04, 2012 9:48 AM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] Sorting a subreport from main report
>
>
>
>
>
> Hi,
>
> I'm using Access 2010, and have created a form and a datagrid subform.
> In the main form, I've created a combobox which allows me to filter the
> datagrid subform by sales rep. This seems to be working fine. Now I
> want to add a couple more options. I want to add a few command buttons
> to the main form which will sort my subform data. For example, I want a
> button that will sort the subform data by job_due_dt. The second button
> would sort the subform data by customer and then by due date.
>
> How would I go about doing this?
>
> Thanks,
>
> Troy Sherven
>
> MCD, Inc.
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>


[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar