Results 1 to 10 of 10
  1. #1
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727

    Sort In Report

    In red is what I am trying to add on to the code. Can anyone tell me where to add my strWhat string? Or if I even need to do this?
    The strWhere that is set for the filter, carries over nicely from the split form to report. I would like to do the same with sorts. If the split form has sorts running, I would like this to carry over to the report as well. How can this be done? Ultimately, I would like the report to look exactly the same as the split form for how the records are listed. Can it be done? This code is behind the open report button on the split form.


    Private Sub cmdPrintReport_Click()
    On Error Resume Next

    Dim strWhere As String
    Dim strWhat As String
    If Me.Dirty Then Me.Dirty = False
    If Me.FilterOn Then strWhere = Me.Filter
    If Me.OrderByOn Then strWhat = Me.OrderBy
    DoCmd.OpenReport "Permit Dates Issued_report", acViewReport, , strWhere, , strWhat
    Me.txtStart.SetFocus

    End Sub


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    There is no argument in the OpenReport method for sort parameters.

    Sorting must be in the report design using Grouping & Sorting features or perhaps code can set the report OrderBy property. I've never tried the latter.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Hmm, I think this is what you are looking for...
    http://www.access-programmers.co.uk/...d.php?t=227013

  4. #4
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Thanks for the reply GinaWhipp. Maybe I am missing something but it sounds like the sorting takes place every time the report is open. In this case the code is for the OnLoad event of the report. I need something that the user can decide how the report is sorted. Do you have any ideas for that? This seems like a pretty close solution though.

  5. #5
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    I don't have anything for that but I know it can be done. You would need a little Form to open with the Report and then you can set your GroupBy's from it. Hmm, sounds like maybe I should make a sample for that... sounds like fun!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Maybe code can set the OrderBy property of report.

    Maybe an expression in the OrderBy property can reference controls on a form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Yes please. If you make something, please post back.

  8. #8
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    June7,

    could you assist with expressions. I tried the VBA code of messing with the OrderBy commands and was not able to get it to work. I think the other command was OrderBy On. I have a FilterBy and FilterBy On VBA code that works great which is why I used the same concept for the OrderBy and OrderBy On but could not get it to work. I know practically nothing when it comes to expressions so if you could help with that, that would be great. Thanks.

  9. #9
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Hmm, will do. Tonight is Friday and I'm not going anywhere, so...

  10. #10
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Well, looks like I don't have to write anything, I found this...
    http://www.databasedev.co.uk/sorting_reports.html

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need to add sort criteria to report
    By pellissier in forum Reports
    Replies: 13
    Last Post: 02-14-2013, 05:57 PM
  2. Report - Can you sort on a formula
    By Lisa Perry in forum Reports
    Replies: 9
    Last Post: 06-07-2012, 03:42 PM
  3. Report Groups and Sort
    By cbrsix in forum Reports
    Replies: 4
    Last Post: 11-18-2011, 02:06 PM
  4. Carrying over sort to report
    By eww in forum Programming
    Replies: 2
    Last Post: 03-04-2011, 03:39 PM
  5. sort data in the report
    By rawandjamal in forum Reports
    Replies: 1
    Last Post: 12-23-2010, 07:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums