Change Order on a Report!

B

Bob V

I want to try and change the order of my Report to show the latest Date
first or the Highest InvoiceID first (Descending)
Thanks for any help with this........................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
Name, [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," _
& " qActiveHorseList.* FROM tblInvoice," _
& " qActiveHorseList where qActiveHorseList.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," _
& " qActiveHorseList.* FROM tblInvoice," _
& " qActiveHorseList where qActiveHorseList.HorseID=tblInvoice.HorseID
And " _
& " tblInvoice.OwnerID=" & Forms!frmInvoiceClient![cbOwnerName]
Debug.Print Report.RecordSource
End If
Debug.Print "Recordsource = " & Report.RecordSource
End Sub
 
K

Ken Snell \(MVP\)

Reports rely on the Sorting & Grouping settings in the report itself for the
ordering of records in the report.

Additionally, you cannot manipulate the Visible property of controls in the
Report_Open event; you need to use the Format or Print event of the report
section that contains those controls.
 
B

Bob V

Thanks Ken , Changed InvoiceID to Descending BRILLIANT thanks for your
help.........Regards Bob

Ken Snell (MVP) said:
Reports rely on the Sorting & Grouping settings in the report itself for
the ordering of records in the report.

Additionally, you cannot manipulate the Visible property of controls in
the Report_Open event; you need to use the Format or Print event of the
report section that contains those controls.

--

Ken Snell
<MS ACCESS MVP>




Bob V said:
I want to try and change the order of my Report to show the latest Date
first or the Highest InvoiceID first (Descending)
Thanks for any help with this........................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
Name, [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,"
_
& " qActiveHorseList.* FROM tblInvoice," _
& " qActiveHorseList where qActiveHorseList.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," _
& " qActiveHorseList.* FROM tblInvoice," _
& " qActiveHorseList where qActiveHorseList.HorseID=tblInvoice.HorseID
And " _
& " tblInvoice.OwnerID=" & Forms!frmInvoiceClient![cbOwnerName]
Debug.Print Report.RecordSource
End If
Debug.Print "Recordsource = " & Report.RecordSource
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top