Conditionally hiding specific field on report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, everyone,

I have a report that shows open product jobs. I have it grouped by product
type. All but one of my products is measured in quantities of bottles; the
'special' product is mesasured in kilograms.

I have both fields on my report, but I want the report to show the bottle
quantity and hide the kilogrammes, unless the product type is the 'special'
one; then I want the report to hide the Bottle Quantity and show the
kilogrammes. I've tried writing an If statement in VBA in the report's
OnOpen event:

If [ProdType] = "Dispense" Then
[BottleQty].Visible = False
[Kgs].Visible = True
Else:
[BottleQty].Visible = True
[Kgs].Visible = False
End If

However, this did not work; I got a debug msgbox that said that the
'property has no value' which I took to mean I used an invalid property for
that control. The report is open from a switchboard.

Any suggestions?

Thanks!
Chris A., Las Vegas
 
Chris:

If I understand you correctly, you could use just one field and set the
Control Source property using an IIF statement.

For example:

=IIF([Product Type]="Special",[Kilograms],[Bottles])

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
 
Since you want to set these 2 Controls differently for each Row in the
Report's RecordSource, you need to use the Format Event of the Detail
Section of your Report.
 
I was able to use a combination of both your and David's suggestion to get it
to work. I put an unbound text control, hid both quantity fields, then in
the OnFormat for the detail section, write the code necessary to point the
unbound control to the desired field.

Thanks a bunch!

Van T. Dinh said:
Since you want to set these 2 Controls differently for each Row in the
Report's RecordSource, you need to use the Format Event of the Detail
Section of your Report.

--
HTH
Van T. Dinh
MVP (Access)



Chris A said:
Hi, everyone,

I have a report that shows open product jobs. I have it grouped by product
type. All but one of my products is measured in quantities of bottles; the
'special' product is mesasured in kilograms.

I have both fields on my report, but I want the report to show the bottle
quantity and hide the kilogrammes, unless the product type is the 'special'
one; then I want the report to hide the Bottle Quantity and show the
kilogrammes. I've tried writing an If statement in VBA in the report's
OnOpen event:

If [ProdType] = "Dispense" Then
[BottleQty].Visible = False
[Kgs].Visible = True
Else:
[BottleQty].Visible = True
[Kgs].Visible = False
End If

However, this did not work; I got a debug msgbox that said that the
'property has no value' which I took to mean I used an invalid property for
that control. The report is open from a switchboard.

Any suggestions?

Thanks!
Chris A., Las Vegas
 
Back
Top