Hasdata head scratcher

opiv6ix

Registered User.
Local time
Today, 12:13
Joined
Jan 13, 2007
Messages
21
Hey all,

Using the information I could find here on the using IIF and HasData to make a report still function with an empty subreport, I seem to have it working. I also used this resource which may be useful to others: Hasdata method.

So I have my Sum of subreport data in the subreport footer. I have my IIf in the main report as such:

=IIf([Sub1].Report.HasData,[Sub1].Report.[txtSum],0)

The strangest thing is occurring. The first record in the report, it comes out correct. The second record of the report, it has the same number from the first record. The third record of the report, it has the number that should be on the second record, and so on.

I made the [txtSum] visible to see if that was the problem, but that calculated value is always coming out correct. It's very frustrating, because the next line down, my IIf statement is one record off (except the first one).

Can anyone point out where my error is? Or is some property of my text box not correct? A page break I missed? :confused:

Thanks for any insight
 
It is in the group footer. Following your train of thought, I find that moving the textbox to the page footer solves the problem. Of course, this gives me a headache to deal with in the layout department. Is there a way to use the hasdata method (or one with a similiar result) and put the results in the group footer?

Basically, the problem becomes, if my detail section outgrows it's space on one page, and sprawls onto the next, then my totals get FUBAR, and the Invoice no longer makes sense if I put the totals in the page footer instead of the group footer.
 
Perhaps you could post a cut down version of your database to the forum.
Stopher
 
Sorry for the delay, been sidetracked for a couple days. Went ahead and stripped the database. I threw in a couple of mathematically simple records so you can see it what's going on pretty easily. Notice that there are no additional charges on the second record, but it gives a subtotal of additional charges from the first record.

Also, I realize that it may appear to have plenty of space for charges, but normally there's a large page header and footer, so the formatting would be a lot nicer if I could keep my totals in the group footer rather than the page footer. Take a look, let me know what you think.
 

Attachments

The last bit of code in your GroupHeader0_Format event is causing the problem:
Code:
If Me.SumInvCharges = "0" Or Null Then
    Me.Additional_Charges.Visible = False
Else
    Me.Additional_Charges.Visible = True
End If

If you comment out this code you'll see that the sub-total passes back to the main report correctly. I suspect the reason is the format event runs before actual detail of the report so hence picks up the "current" subreport info which is still the info from the subreport corresponding to the last record.

Anyway, if you want the Additional_Charges label to appear only when there are subreport records, then simply put the label in a group header (LoadID which you'll need to add) of the subreport.

hth
Stopher
 
Wow, I really didn't expect that. Thanks a lot, your advice cleared it right up, and it works for my formatting. Thanks again.
 

Users who are viewing this thread

Back
Top Bottom