brother
08-27-2009, 12:12 AM
Hi,
I'm working on a report that contains two subforms.
I want the text in [SubReport1]![Field1] to be put in bold for every record where [SubReport1]![Field1] and [SubReport2]![Field1] are alike.
Can anyone of you guys help me on my way with some code on this one? :)
Thanks!!
GalaxiomAtHome
08-27-2009, 04:25 AM
I assume the subreports are both linked to their parent report.
Try this for the conditional format of Field1 on SubReport1:
Value | Equals | Me.Parent.SubReport2.Report!Field1
This link might help:
http://support.microsoft.com/kb/209099
brother
08-27-2009, 05:32 AM
Thanks Galaxiom,
I have tried the conditional format for Field1 and it kind of works. You see, it only formats the first record where the two are alike. The second, third record and so on is left without formatting.
Any clues as to how I solve this?
GalaxiomAtHome
08-27-2009, 06:36 AM
It is certainly an unusual problem. Conditional Formatting is usually based on comparing with a textbox or another field. But to compare fields in two different subreports? And unfortunately I have very little experience in reports.
Totally speculative and probably completely crazy. I don't even know if you can do this in conditional formatting let alone put a recordset in the domain argument of a DLookUp.
DlookUp("field1","Reports!mainreportname!SubReport2.RecordSet","Reports!mainreportname!SubReport1.Report!IDfield=R eports!mainreportname!SubReport2.RecordSet!IDfield")
Even if it does work I suspect it would do much like the other idea. I doubt it is even a valid expression let alone effective but I'm curious now.
Otherwise I think you have to use VBA in the OnPrint event of the Main Report Detail Section. No experience in this unfortunately but try somethng like this:
With Me!SubReport1.Report!Field1
If .Value = Me!SubReport2.Report!Field1 Then
.FontWeight = 6
Else
.FontWeight = 3
End If
End With
Expect it is numbers from 0 to 8 for fontwight.
Good luck. However I supect you might have to rethink your strategy.
I like to think VBA can do anything but this is really pushing it.
brother
08-28-2009, 02:07 AM
Thanks for the input :)
It seems that the conditional format only compares the two fields for each record, and not the recordset as a whole. I ended up editing the query behind SubReport2 to include Field1 from Subreport1. I then set the join properties to "include all records from QrySubform2 and only those records from QrySubform1 where the joined fields are equal".
This makes it easy to set up a conditional formatting within Subform2 without having to pay attention to Subform1.
GalaxiomAtHome
08-28-2009, 03:30 AM
Of course! :o. You can put them in them in the Recordset without displaying them in the subform. Literally a case of needing to look outside the square.
My faith in Access and VBA being able to achieve anything lives another day.:D