Determining a Report Title Based on Criteria

M_S_Jones

Registered User.
Local time
Today, 22:09
Joined
Jan 4, 2008
Messages
119
I have seen several posts on here on this topic, but none have provided me with a concise implementable answer, and I'm in a bit of a hurry. I have a report that must have one of three titles, depending upon the information returned in the report query. If no instances of a value are returned, then one title is needed, if all of the instances returned match that value then I need another, and if there are some and some then I need yet another. I've attempted to tackle this using DCount, assigning the DCount result to a variable in the On Open event of the report, and then an if statement: if the variable containing the result of the DCount equals zero then label1.visible = true; but this generates an error, saying that I cancelled the previous expression. Can anybody tell me an easy way of achieving my desired functionality? I'd be very grateful!

Thank you,

Matt
 
use a label

in the report open event do whatever test you want

but the property is caption, so you want

mylabel.caption = "whatever"

----------
mycount=dcount("*",me.recordsource)

select case mycount
case 0; label1.visible = false
case 1; label1.caption = "1 item"
case else: label1.caption = "wahatever
end select

this should work
 
Thank you for your reply, Gemma-the-husky. I think that my main problem was that I was trying to format objects on open, because when I tried executing your code it generated errors too. However, I've tried it in the Format event for the report header and it works a treat! I never knew about .caption, it's a lot easier to work with than layering multiple labels over each other and only making one visible at a time! Thanks again,

Matt
 
funny, setting header details ought to work in the report open event

mind you, thats the overall report header, not a section header - if you are formatting a section you will need to use the format event
 
You can change the captions of Labels in Report Open
Me.Labelname.Caption =


Brian
 
I'm aware of that, it was the DCount that it didn't like in there. I'm happy with it working in the format event, it functions as I'd hoped it would.
 

Users who are viewing this thread

Back
Top Bottom