Results 1 to 8 of 8

Thread: sort A-Z & Z-A

  1. #1
    Join Date
    Nov 2004
    Posts
    64

    Unanswered: sort A-Z & Z-A

    I need to be able to have the columns in a continuous form sorted a-z & z-a at the click of a button. could you help me with the code or point me in the right direction to find it

    Thanks

    Peter

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Sorting

    One way of doing it (but it may not be the best way) is to set the Record Source to a query (or SQL statement) - one sorted A-Z and the other sorted Z-A depending on which button they click. But they can also right-click on any of the fields and sort the records Asc or Desc (if you have the Shortcut Menu = Yes on the subform).

    For example on the A-Z button click with setting the RecordSource:
    Forms!MainForm!MainSub.RecordSource = "qrySortedA-Z"

    Others might have some easier suggestions though.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    If you havent modified the default toolbars in Access, click the column you wanted sorted then clikc the A-Z button for ascending, or Z-A for descending.

    I still find it amazing the number of applications I come across where someone has tinkered witht he default toolbars and thus remove some of the functionality of access. Things such as filters, sort seequences etc. Leaving the toolbar accessible removes the need for all sorts of code.

    I still don't understand the mentality of some users, ie how they view THEIR data. So it seems imprudent to remove toools which may make their life easier by letting them apply whatever searches, filters etc they wish.

  4. #4
    Join Date
    Nov 2004
    Posts
    64
    Sorry I think I need to add a little more information

    I was using the right click and sort the records Asc or Desc system but I changed the database from mdb to mde. As a mde I lost the use of the right click and sort , the Shortcut Menu is set to “Yes”

    Thanks for your suggestions so far
    Peter

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    in which case then you need to follow Paul Kohn's suggestions and place a button on the form which alters the forms underlyting recordsource, or sets the forms order by properties. Off hand I would chaneg the forms underlying recordsource

    eg
    cmdButton_click
    if cmd_button.caption="Sort Descending" then
    me.recordsource="select blah , blah1 from tblYuck order by blah DESC"
    cmd_button.caption="Sort Ascending"
    else
    me.recordsource="select blah , blah1 from tblYuck order by blah ASC"
    cmd_button.caption="Sort Descending"
    endif
    me.requery 'not sure if you need to do this, so first off don't include it and see if the form works ok

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Sorting A-Z

    Peter,

    I haven't encountered any problems with using the shortcut menu (right clicking on a field) and then sorting when creating an MDE. Are you sure there isn't anything else going on which prevents this? I've been able to utilize this in MDEs.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd guess as part of your MDE deployment you are restricting the toolbars available to the user. Like Paul K I've used the standard toolbars in a MDE, I've also created toolbars where required.

    Personally I don't like having to write code to replace functionality that is already built in to the applciation. Depsite what the Microsoft haters claim to me Access seems to do a heck of a lot of what is required out of the box with then minimum intervention of the developer. I'f far rather depend on their debugging manpower than spread my limited testing time to cover such functions.

  8. #8
    Join Date
    Nov 2004
    Posts
    64
    The answer is found
    healdem your comment
    "I'd guess as part of your MDE deployment you are restricting the toolbars available to the user"

    the "Allow default shortcut Menus" in the start up properties were set as "not allowed"

    with every bodies efforts, it built up enough of a picture to suggest I should check out the startup properties

    many many thanks to you all

    Peter
    Last edited by Peter.t; 02-21-05 at 21:42.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •