RE: Order By property



Hi, Nikki.

In form design view, view properties with View, Properties and click the
square at the top left of the form to display the form's properties. Click
the Event tab, then click into the On Open field. Click the ellipsis to the
right of the field, and choose Code Builder if prompted.

Access will create the shell of a Visual Basic OnOpen event procedure.
Between the Sub and End Sub lines, enter the following code:

Me.OrderBy = "MyOrderByField"
Me.OrderByOn = True

Replace MyOrderByField with the name of the field (or fields, separated by
commas) you wish to order by, and include the quotes to make it a string
value. Save the code and the form and you're in business.

Hope that helps.
Sprinks


"NikkiB" wrote:

> Hi,
>
> I have an inquiry Form linked to a query which prompts for Criteria. I have
> set the Order By Property to FieldABC but once the report opens in continuous
> form view I allow the users to "re-sort" the data. I provide them with a
> custom toolbar containing the Sort Ascending and Sort Descending menu items.
> This all works great except...
>
> Once the user "re-sorts" the data it overwrites my original OrderBy Property
> setting. Is there a way in VB that I can reset the sort order using the
> OnOpen Event? I tried to use the acCmdSortAscending but do not know how to
> write VB.
>
> Any input would be greatly appreciated.
>
> Thanks so much for your help.
>
> Nicole
.



Relevant Pages

  • RE: Order By property
    ... "Sprinks" wrote: ... > Access will create the shell of a Visual Basic OnOpen event procedure. ... > Between the Sub and End Sub lines, ... >> custom toolbar containing the Sort Ascending and Sort Descending menu items. ...
    (microsoft.public.access.forms)
  • Re: Need to order a Listview....
    ... Private Sub Form_Load ... 'Use default sorting to sort the items in the list ... ' lParam As Long ... 'CompareValues: This is the sorting routine that gets passed to the ...
    (microsoft.public.vb.general.discussion)
  • Re: Need to order a Listview....
    ... Randy Birch schreef: ... Private Sub Form_Load ... 'Use default sorting to sort the items in the list ... 'CompareValues: This is the sorting routine that gets passed to the ...
    (microsoft.public.vb.general.discussion)
  • Re: Setting to force start menu & favorites to list in alphabetical order?
    ... vbs file sorts the menu alphabetically with sub menus at the top. ... To sort a menu with IE5's Desktop Update, ... ReportErrors "Updating App Paths" ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Setting to force start menu & favorites to list in alphabetical order?
    ... > vbs file sorts the menu alphabetically with sub menus at the top. ... To sort a menu with IE5's Desktop Update, ... > ReportErrors "Updating App Paths" ...
    (microsoft.public.windowsxp.help_and_support)