Sort Not Working

  • Thread starter Thread starter John
  • Start date Start date
J

John

There are two headers (header 1 has labels and text boxes
and header 2 only has labels) along with the details. The
fields sorted actually show up in the header (allows me to
hide the details for a summary report).

There is code in the report.
OnNoData . . . displays a message and cancels the report.
OnOpen . . . sets the two sort fields as needed and
changes the report title (Case Select).
 
Sure.
The code is as follows:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is not data for your report." _
& vbCrLf _
& "Please change your options and try again.",
vbOKOnly, _
"No Report Data"
Cancel = True
End Sub

Private Sub Report_Open(Cancel As Integer)
Dim intReport As Integer

intReport = Forms("frmMainMenu")!txtReportNumber

Select Case intReport
Case 111
'Nothing to do - Sort by Product with Detail
Case 112
'Sort by Product without Detail
Me.lblPageSubTitle.Caption = "by Product
without Detail"
Me.GroupHeader1.Visible = False
Me.Detail.Visible = False
Case 121
'Sort by Type by Product with Detail
Me.lblPageSubTitle.Caption = "by Type by
Product with Detail"
Me.GroupLevel(0).ControlSource = "Type"
Me.GroupLevel(0).SortOrder = False
Me.GroupLevel(1).ControlSource = "Product"
Me.GroupLevel(1).SortOrder = False
Case 122
'Sort by Type by Product without Detail
Me.lblPageSubTitle.Caption = "by Type by
Product without Detail"
Me.GroupLevel(0).ControlSource = "Type"
Me.GroupLevel(0).SortOrder = False
Me.GroupLevel(1).ControlSource = "Product"
Me.GroupLevel(1).SortOrder = False
Me.GroupHeader1.Visible = False
Me.Detail.Visible = False
Case Else
MsgBox "The report options selected are not
valid." _
& vbCrLf _
& "Please reselect your options and
try again.", vbOKOnly, _
"Invalid Options"
Cancel = True
End Select
End Sub
 
Note on previous code, that the "default" report is by
product with detail and even if that is the report
selected then still does not sort / group correctly.
 
I would look to make sure the text boxes are in the correct sections and the
sections are visible. If you aren't seeming to lack records that are in the
report's record source then I expect your text boxes are in a group section.
 
Thanks Duane!

I got the report working. I got the idea from your
response on a more recent post and this reply confirmed my
idea.

I did have text boxes in the headers (as I needed to), but
I added another header for the product and moved the text
boxes down to the new header and everything works now.

Thanks.
 
Back
Top