Question : Conditional formatting based on previous record detail

I have a report which serves as a  manufacturing worksheet in our factory and it shows the cutting sizes for pieces of material.

Our cutters keep making a mistake when there is multiple cuts at one size (e.g 1500mm) and then one at another size (e.g. 1800mm). For some reason they get in a groove and accidentally cut the 1800 at 1500.

To make it more obvious I want to make a conditional format that makes the 1800mm Bold if the two previous records are the same.

Anyone got any idea what expression I could use to say -

If currentrecord - 1 = currentrecord - 2 but <> currentrecord

Thanks,

Andrew

Answer : Conditional formatting based on previous record detail

Before any Subs or Functions in the code module behind the report, created two public variables.

Public intPrev as Integer, intPrev2 as Integer

In the On Print event of the Detail section of the report, assuming a textbox named tbxSize bound to the field Size:

Private Sub Detail_Print()
 
  intPrev2 = intPrev
  intPrev = Me!tbxSize

End Sub

Now set the Conditional Formatting for the Size control  to the Expression

(intPrev) = intPrev2) AND (Size <> intPrev)

selecting Bold if true

In pseudo code every time the report prints a Size, it executes the Print() event code.  Then when the individual control containing Size is formatted, you will get a BOLD format if the two previous records were equal but are not equal to the current record - at least that is the intent and logic behind my suggestion.
Random Solutions  
 
programming4us programming4us