locked
Is there a way to prevent users from sorting records? RRS feed

  • Question

  • Is there a way without going to the Other Tab and setting Shortcut Menu = No, to prevent the user from sorting records of a Datasheet? I've looked through the events and the closest I see is Filter. I know there is an OrderBy and OrderByOn property, but I can't think about how to catch when user does sort. I've already removed the ribbon so they can't use that. Is there some way to prevent sorting of records?
    Tuesday, February 14, 2017 1:10 PM

Answers

  • Yes, in the form's Property Sheet: change the 'Records Locks' property to: All Records

    The right click sort feature will then be disabled

    • Marked as answer by HTHP Tuesday, February 14, 2017 4:10 PM
    Tuesday, February 14, 2017 2:28 PM
  • Hi,

    Sorry for the confusion, it's not exactly as I remembered it. Looking at a form, this is what I meant:

    Hope it helps...

    • Marked as answer by HTHP Tuesday, February 14, 2017 4:10 PM
    Tuesday, February 14, 2017 4:01 PM

All replies

  • Hi, Have you tried the On Apply Filter/Sort event?
    Tuesday, February 14, 2017 1:28 PM
  • Yes, in the form's Property Sheet: change the 'Records Locks' property to: All Records

    The right click sort feature will then be disabled

    • Marked as answer by HTHP Tuesday, February 14, 2017 4:10 PM
    Tuesday, February 14, 2017 2:28 PM
  • DbGuy: Are you sure that is an event? I can only find OnFilter, and when I set that one to Cancel = 0, it still sorts.

    As for msdnPublicIdentity's suggestion, I'm having trouble setting Me.RecordLocks = 1("All Records"). When I do this in Open/Load events, it says the tblOrderLines is locked by another user, and won't open the form(which is bound to that table). I need to manipulate those records in code too via the Form.Recordset, how should I attempt locking records to prevent sort?
    Tuesday, February 14, 2017 3:07 PM
  • Hi,

    Sorry for the confusion, it's not exactly as I remembered it. Looking at a form, this is what I meant:

    Hope it helps...

    • Marked as answer by HTHP Tuesday, February 14, 2017 4:10 PM
    Tuesday, February 14, 2017 4:01 PM
  • Thanks, Both approaches seem to work. As for the lock trouble I was having, you have to set RecordLocks = 1 before binding the form to the table.
    Tuesday, February 14, 2017 4:11 PM
  • Hi,

    Glad to hear you got it sorted out. Good luck with your project.

    Tuesday, February 14, 2017 4:24 PM