Log in

View Full Version : [SOLVED:] Hide or show report data



GaNGeR_
03-07-2007, 05:49 PM
Hi, don't know if this is too easy, but eitherway, I'm struggling with it so...

I've made a report to send monthly invoices. For each costumer, I have two adresses, one showing the street and matching state, zipcode, one showing the PO Box with matching state, zipcode. If I show them both, it's a bit too much on the report.

I only want to show the street and matching data if there's no PO Box available. Can't do this with a query (I think) because all records need to be involved, sometimes they just have to be hidden, at least some of it.

any ideas?

Thanks

Brandtrock
03-07-2007, 10:46 PM
Your query could be something like this:


=IIf([Your_PO_Box_FieldName] Is Null,[Your_Street_FieldName] & " " &[State] &" " &[PostalCode],[Your_PO_Box_FieldName] & " " &[State] &" "& [PostalCode])



Regards,

GaNGeR_
03-07-2007, 11:31 PM
thanks, but that doesn't seem to work.

I also don't want to put it in the query because then it just ecludes the data.

I make an action query that gives me all the invoices that should be send. afterwards, I make a report from all the ID's that appear in that table, but with the data like name and PO box,... included. I always want PO Box and Street included, I just don't want to show one when the other one is filled out.

maybe that's what your thing does, but it gives an error when I do it. have tried to place it in the query and when that didn't work out, placed it in the control source of the report, both gave me an error.

Brandtrock
03-08-2007, 01:48 AM
I just yoinked some code from the Northwind Invoice report address boxes and hacked it up a bit. The code is supposed to return the street address if the PO box is null.

Regards,

OBP
03-08-2007, 08:17 AM
GaNGeR, you can do this easily with VB code, but it has to go in the Report's Detail "On Format" Event Procedure.
To access the Detail's "On Format" Event Procedure, right click the "Bar" that seperates the Header and Detail sections.
In the Event Procedure you will need to put something like this -

If IsNull(me.PoBox) then
me.street.visible = no
else me.street.visible = yes
end if

GaNGeR_
03-08-2007, 04:09 PM
Thanks, that should work once I get it right (haven't got it yet...)

At the moment the label Street is still showing, but the text is always gone, I copied it as you posted it, with some minor adjustmebts for the names...

Also the PO Box needs to be gone once the street is filled in, I could probably figur that one out myself once I get the other code right I think...

For town and state, do I just repeat the code with and in between and the proper names, or is there a way to implement this in the first code?

Thanks once again, this does seem to work, only not the way it should yet, but I'll get there.

OBP
03-08-2007, 04:27 PM
Yes you can set as many fields to "Visible" or not in the first set of code.
i.e.

If IsNull(me.PoBox) then
me.street.visible = no
me.town.visible = no
me.state.visible = no
else
me.street.visible = yes
me.town.visible = yes
me.state.visible = yes
end if

and


If IsNull(me.Street) then
me.pobox.visible = no
else
me.pobox.visible = yes
end if

GaNGeR_
03-08-2007, 05:42 PM
can't help it, but the minute I paste your first code where you told me to paste it (and with the right names as it's PO_Box in this case) The text box of street dissapears everywhere...


If IsNull(me.PO_Box) then
me.Street.visible = no
else me.street.visible = yes
end if

tried, switching the yes and no but nothing works.

at least something dissapears but not really what I had in mind.

GaNGeR_
03-08-2007, 06:19 PM
Ok, got the answer, somehow it does respond well to true and false instead of yes and no...

Thanks for helping me on the way!

OBP
03-09-2007, 03:02 AM
GaNGeR, sorry about the Yes/No - True/False mistake, I was working from memory, and at 60 it is not as good as it once was.:mkay