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

Changing visibility of same report detail field with different records 1

Status
Not open for further replies.

jhays

Technical User
May 23, 2002
9
US
I have been working on this off and on for quite a while. I have a report that takes it's detail fields from a subform. I have 6 of each of the following fields: quantity , unit of measure, and price (quantity1,unitofmeasure1,price1,quantity2,unitofmeasure2,price2, ...all the way up to quantity6,unitofmeasure2,price6)

The quantity1, unitofmeasure1, and price1 fields are always visible on the report. But, the visibility of the rest of the sets of fields depends on whether or not they have data in the corresponding quantity field on the subform.

This works just fine for the first record on the report. But my problem is that every record on the subform is its own section on the report. The first record may have data in the quantity2, and I want the price2 or unitofmeasure2 fields for Record #1 to print on the report. But the quantity2 field on the second record of the subform may not contain any data so I don't want the price2 or unitofmeasure2 fields to print on the report.

As it is right now, if any of the records have a value in the quantity2 field, then the report prints all of the records as if they contain data in that field.

Is there a way to reset the the visible = false after each record in the report or limit the visibility of the fields to be based on the data in that specific record?

Thanks
 
Hi jhays

You need some code in the OnFormat event of the Detail section of your report. This event happens each time a record is printed to your report, so you can make stuff change from line to line depending on the values in each record.

For instance, you could have something like...
Code:
Select Case Me.Quantity2

     Case Null
         Me.Quantity2.Visible=False

     Case Else
         Me.Quantity2.Visible=True

End Select

This should evaluate the value of the field Quantity2 in every record, and either display or hide the field on the report depending on whether it has a value.

Hope this helps!
 
Or a shorter version of the same code.

me.quantity2.visible=not isnull(me.quantity2.value)

 
MacCaillean ,
The OnFormat was the key. I just put my code there, and it worked! Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top