Conditional formatting of labels?

A

Andy

Hi

I have a report that produces a sales slip for a point of sales application.
The report produces a list as follows:
Quantity, Description, Unit Price, Discount, Total Price

However, when discount is null I don't want the label "Discount" to show in
the header, else customers feel hard done by because they did not get a
discount. I could do this with conditional formatting, except that if I
click on a text label the Conditional Formatting menu option is greyed out.
(MS Access 3002). Any ideas?

Thanks
Andrew
 
S

SA

Andy:

one way to do this is to eliminate the label and change your control source
to include the moniker "Discount" as part of what's displayed. Here's how
you could do it.

Set the "Discount" Control's control source to nothing, making it unbound.

Set the controls height to .0007 and its can grow property to True (you
might want to do this step last so that you get the rest of this right
first)

Then in the On Format event of the section that contains the control add
code like this:

If FormatCount = 1 Then 'lets not do this repeatedly if Access
multi-formats the section
If Me.YourDiscountField > 0 or Not IsNull(Me.YourDiscountField) Then
'You may need to use the Format() function to format the discount
Me!YourDiscountControl = "Discount: " & Me.YourDiscountField
End if
End if

That way if there's no discount, the control is empty and it won't grow to
display it, if it isn't empty then it will display

Now the only catch to this is if you are using the report to sum the costs,
discounts etc. into a total, doing the discount this way would render the
totals created in the report invalid, so you'll have to calculate the total
in either the underlying query or by adding hidden controls that duplicate
the fields you are summing on the report.
 
D

Duane Hookom

I would change the Discount label to a text box. Set the control source to:
="Discount: " + [Discount]
Allow the text box to shrink but not grow. Make the width only enough to
display "Discount".

If the field [Discount] is null, the entire text box will be null.
 
A

Andy

Hi

A solution I worked out for myself while playing with this further is to
delete the label and replace it with a text box. The source of the text box
I set to ="Discount". I could then access the conditional formatting for the
unbound text box, and so I was able to set this to white text on a white
background if the discount = 0.

Perhaps not the best solution, but it did work.

Thanks everyone for the help you have given.

Andrew
Duane Hookom said:
I would change the Discount label to a text box. Set the control source to:
="Discount: " + [Discount]
Allow the text box to shrink but not grow. Make the width only enough to
display "Discount".

If the field [Discount] is null, the entire text box will be null.

--
Duane Hookom
MS Access MVP
--

Andy said:
Hi

I have a report that produces a sales slip for a point of sales
application. The report produces a list as follows:
Quantity, Description, Unit Price, Discount, Total Price

However, when discount is null I don't want the label "Discount" to show
in the header, else customers feel hard done by because they did not get
a discount. I could do this with conditional formatting, except that if I
click on a text label the Conditional Formatting menu option is greyed
out. (MS Access 3002). Any ideas?

Thanks
Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top