Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    163
    Thanks
    2
    Thanked 0 Times in 0 Posts

    sorting records on a form or report

    Hi,

    In my database the records can be sorted in several different ways. I gave them all a UID (unique identifier) so that they could be sorted chronilogically. However most of the items are also tied to reference numbers. I can sort the table by reference number, but when I go to my report or form the records will not sort properly. I need to compare records with the same reference numbers to see if they overlap and can be combined into one entry.

    I tried this code


    Private Sub Command19_Click()
    Private Sub CmdSort_Click()
    Me.OrderBy = "Reference"
    Me.OrderByOn = True
    End Sub
    End Sub

    Private Sub Sort_by_Reference_Click()

    End Sub

    But it doesn't seem to work.
    Can someone suggest what I might do to get my records sorted on either the form or report?

    Thanks.

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: sorting records on a form or report

    I'm not sure about the code, but ... Couldn't you use a query, that sorts the table records the way you want to see them, as the source of the form or report?

  3. #3
    ravey
    Guest

    Re: sorting records on a form or report

    The code you included seems to be parts of several different procedures, so I can't comment on it. But you don't need to use any code, anyway. Just base your report (or form, for that matter) on a query that has the desired sorts indicated.

  4. #4
    Star Lounger
    Join Date
    Dec 2000
    Location
    Hellertown, Pennsylvania, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: sorting records on a form or report

    Your code has too many lines - Try this:
    Private Sub CmdSort_Click()
    Me.OrderBy = "Reference"
    Me.OrderByOn = True
    End Sub

    You may want to Me.Refresh after the OrderByOn property. Don't know if you need it, though.....

    Also, try referencing the form as

    Forms("frmname").OrderBy="Reference"

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    163
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: sorting records on a form or report

    Thanks for the replies.
    I tried the new code, but it still wouldn't work, so I went back and created a query as suggested and now have the form in the order that I wanted.

Posting Permissions

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