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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to group and sort

Status
Not open for further replies.

rgao

Technical User
Feb 1, 2002
38
CA
Hi,here is a question about sort and group.

we know in Access report is easy to group and sort data,but the report is not interactive,you can't click and choose data from it.
Since i want it interactive,so I have to choose form to display data,does anyone know how to group and sort data in form?
eg: the form display the data of products,first we want it grouped by shop where they're stored, within the group we want it ordered by quantity,it looks like this:
shops products Qty
s1 p1 50
s1 p6 40
s1 p7 30
s2 p1 70
s2 p2 60
........
Can you help?
 
Use either datasheet view or continuous forms. Either way, your ordering and grouping will take place in the query, and the data will be loaded in that order to the form. Sean.
 
I don't know if this will help but I use the following for filtering in a form (Access 97). Using a button the on click code is:

On Error GoTo Err_FiltBySelect_Click

Screen.PreviousControl.SetFocus

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 0, 1, acMenuVer70

Exit_FiltBySelect_Click:
Exit Sub

Err_FiltBySelect_Click:
MsgBox Err.Description
Resume Exit_FiltBySelect_Click

This will add filtering so that selecting a second form field and clicking again will filter on both criteria. The filter is removed by a second button with this command

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 3, , acMenuVer70


Sorting is achieved by a similar process, for an Ascending sort

Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 0, acMenuVer70

and for a descending sort

Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 1, acMenuVer70

by a combined use of these I can usually display the required data in the required order.

There is also the Filter property of a form which could be used in code, in the same way you build SQL

Me.Filter = "Country = 'USA'"
Me.FilterOn = True
 
The Microsoft Knowledge base article

ACC: How to Filter a Report from a Pop-Up Form (Q147143)

might help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top