Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing last record in report when used as subreport

Status
Not open for further replies.

alexisb

Programmer
Apr 5, 2001
100
US
Hi! I have created a subreport that shows the heading only on change of a type field. This subreport works fine when I run it on its own. However, when it runs as part of the main report, I am losing the last record in the subreport. When I put test messages in the logic that does the hiding/displaying of the header section, I can see the last record is there. I can't figure out why it is not displaying. The data source is a query sorted by a sequence number. The query data also looks fine.
Here's the logic on format of the header section:
Option Compare Database
Dim lastquestiontype As String

Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)
MsgBox lastquestiontype & " " & Me.QuestionType & " " & Me.QuestionDesc & " " & Me.QuestionResponse
'ck question type of each record coming in so can display header only on change of type
If lastquestiontype <> Me.QuestionType Then
' MsgBox "true"
Me.GroupHeader2.Visible = True
Else
' MsgBox "false"
Me.GroupHeader2.Visible = False
End If
lastquestiontype = Me.QuestionType
End Sub
For example, I have 4 records. Two have type Blue and two have type Red. I should see:
blue
rec 1
rec 2
red
rec 3
rec 4
But I am not seeing rec 4 even though my test messages show red and the rec 4 data before ending.

Does anyone have any ideas? I must be missing something obvious.
Thanks,
Alexis
 
Please disregard this question. I worked on it some more and realized that my code is fine. The problem is that the report is wrapping strangely to the next page and leaving a large blank space so I didn't even realize it was on the next page. I'll fix the page break logic.
Sorry about that.
Thanks,
Alexis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top