none
Report sort order! RRS feed

  • Question

  • I am trying to get this report to sort by  InvoiceID Descending ...Thanks for any help.........Bob

    Private Sub Report_Open(Cancel As Integer)

    If CurrentProject.AllForms("frmHorseInfo").IsLoaded Then
        Report.RecordSource = "SELECT Distinct tblInvoice.InvoiceDate,tblInvoice.InvoiceID AS InvoiceID," _
        & " tblHorseInfo.HorseID, funGetHorse(0,tblHorseInfo.HorseID,false) AS HorseNamed, [StableReturnDate] " _
        & " FROM tblInvoice,tblHorseInfo where tblHorseInfo.HorseID " _
        & " = tblInvoice.HorseID" _
        & " and tblInvoice.HorseID=" & Forms!frmHorseInfo![tbHorseID]
        Report_rptHorseExpenses.tbInvoiceDate.Visible = False
    ElseIf CurrentProject.AllForms("frmInvoice").IsLoaded Then
        Report_rptHorseExpenses.tbInvoiceDate.Visible = True

        Report.RecordSource = "SELECT tblInvoice.InvoiceID AS InvoiceID," _
        & " qActiveHorseListFiltered.* FROM tblInvoice," _
        & " qActiveHorseListFiltered where qActiveHorseListFiltered.HorseID=tblInvoice.HorseID And " _
        & " tblInvoice.HorseID=" & Forms!frmInvoice![cbHorseName]


    ElseIf CurrentProject.AllForms("frmInvoiceClient").IsLoaded = True Then
        Report_rptHorseExpenses.tbInvoiceDate.Visible = True
        Report.RecordSource = "SELECT tblInvoice.InvoiceID AS InvoiceID," _
        & " qActiveHorseListFiltered.* FROM tblInvoice," _
        & " qActiveHorseListFiltered where qActiveHorseListFiltered.HorseID=tblInvoice.HorseID And " _
        & " tblInvoice.OwnerID=" & Forms!frmInvoiceClient![cbOwnerName]
    Debug.Print Report.RecordSource
    End If
        Debug.Print "Recordsource = " & Report.RecordSource
    End Sub

                   

    xxx

    Thursday, September 3, 2015 1:31 AM

Answers

All replies

  • Hi. It doesn't matter if your record source is sorted or not, you still need to set the sort order of the report either manually or code. 
    Thursday, September 3, 2015 2:21 AM
  • Thanks Guys...........Bob

    Private Sub cmdPrint_Click()
      DoCmd.OpenReport "rptHorseExpenses", acViewPreview
      SendKeys "{End}", True

    End Sub


    xxx

    Monday, September 7, 2015 2:28 AM
  • Hi Bob. You're welcome! Glad we could assist. Good luck with your project.
    Monday, September 7, 2015 3:37 AM