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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reference subreport control source fields

Status
Not open for further replies.

lorirobn

MIS
Mar 15, 2005
450
US
Hi...

I am writing a report that contains a subreport. On my main report, one report page is one row of data from "TableMain". At the bottom of the page is the subreport, which displays 1 line of data per row from "TableSub" (like a 'continuous form', but not sure what it is called for reports).

If fields contain certain values, I hightlight them. I check for these values, and print '**' if necessary. This works on the 'Main' page. But for the subreport, all lines print according to the first row on that page. For example, if the first row of data on a page is highlighted, the second row will be highlighted, too, even if data should not be. And if the first row is not highlighted, second row will not be, even if it should be.

I had the highlighting logic for the subreport in the Detail_Format event of the main report's module. Is this incorrect? Where should it be? I tried putting it in the Detail_Format event of the subreport, but cannot figure out how to reference it.

Can someone please help on this. It's so small, but taking me so long to figure out...

THANK YOU!
Lori
 
Hi
I have a feeling you need to use conditional formatting for a continuous subform. [ponder]
 
Remou,

That is soooo great!!! I did it, and it worked.
I never used conditional formatting before. Being a reformed Cobol programmer, I programmed it by putting '***' next to each field! Yikes. Just undid all that, and did the conditional formatting - nice and easy, and looks good, too!

But still would be curious, if I did want to format them on my own - WHERE would I do it, for a subreport? If anyone feels so inclined to let me know that, for future reference.

Thanks,
Lori
 
Prior to conditional formatting we used code in the On Format event of the report/subreport. There are a couple key points:
1) If you set a property in the on format, you need code to un-set it. The property doesn't automatically revert back.
2) you can't reference the value of an unbound field from your report's record source.
Code:
If Me.txtOverDueAmt > 1000 Then
   Me.txtOverDueAmt.ForeColor = vbRed
  Else
   Me.txtOverDueAmt.ForeColor = vbBlack
End If


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Ok, I had the code right, but questioned location. So, if txtOverDueAmt was on the subreport, that IF statement would go on the On Format event of the subreport? With prefix of 'Me!', just like you wrote it?


 
Yes, the code would be in the On Format event of the section containing the control.

The On Formate event of a report is somewhat similar to the On Current event of a form.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top