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

Visible vs. invisible 1

Status
Not open for further replies.

ailyn

Programmer
Sep 15, 2005
108
BE
I've got a repport with several subrepports. The important thing is that I need it to show or hide two of them depending if they have a value or not. I made this code for it, it works perfectly on a form but on the report it doesn't do anything ?.?
I may be using wrong terms but I don't get any error either:
Private Sub Report_Open(Cancel As Integer)

If IsNull(Report.SubProf_cust) Then
Report.SubProf_cust.Visible = False
Report.SubProf_ssel.Visible = True ' No customer record
Else
Report.SubProf_cust.Visible = True
Report.SubProf_ssel.Visible = False ' Customer exists
End If
End Sub

The subreports are obviously: SubProf_cust & SubProf_ssel
The value that must be present is 'CustomerId' from SubProf_cust, otherwise the other subform can show instead.
It's for the ship address part of the repport.
 
You may test the HasData property:
Me!SubProf_cust.Visible = Me!SubProf_cust.HasData

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I'm not sure why you need to make a subreport with no data invisible. This is the natural behavior of subreports.
No data, No visible subreport
That's the default behavior.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Sorry, PHV, it doesn't seem to work.
& Dhookom the problem would be solved on its own should that be the case, but I need to show a shipment address. When the customer has been entered in the file it will be shipped to the customer, otherwise to the seller. The info of the seller is always present so I need to avoid the info of the seller from showing when the customer has been entered.
Main report Prof has
tblprof with:
profId
customerId (from tblcustomers)
sellerId (from tblsellers)
profinfo...

subreport SubProf_cust has
tblcustomers
customerId
customeraddress

subreport SubProf_ssel has
tblsellers
sellerId
selleraddress

I hope that helps you see what I intend to do.
 
And this ?
Me!SubProf_ssel.Visible = Not Me!SubProf_cust.HasData

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry, PHV.

Private Sub Report_Open(Cancel As Integer)
Me!SubProf_ssel.Visible = Not Me!SubProf_cust.HasData
End Sub

It doesn' work. The report doesn't show and the error gets filtered marking your code in yellow.
 
What happens if you have the two subreports overlayed with the customer information brought to the front. Make sure the subreports are exactly the same size and their top properties are the same.

I would expect if the customer subreport was empty, the seller subreport would show.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Well, that it works!
Thanks a lot Dhookom! the simplest yet the best solution XD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top