1 (edited by joshuA 2021-11-03 21:55:29)

Topic: [SOLVED] Hide a Memo field

Hey report gurus,
.
I'm hoping to solve this without posting a project... because it's a snippet.
.
I am simply trying to hide a (I'm not sure what they're called in Reports) Memo field maybe?

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
  if Memo1.Value = '00:00' then
    Memo1.Visible := False;                                                                   
end;

.
The field is referencing a DateTime field from the database.  And it is formatted to only show the time as hh:mm.
.
Is there a way to test the contents (for conditional formatting type stuff)?  I have tried Memo1.Value and Memo1.Text... are there any other properties to test for this?
.
Thanks in advance,
-joshuA

"Energy and persistence conquer all things."

2 (edited by sparrow 2021-11-03 09:56:10)

Re: [SOLVED] Hide a Memo field

Hi,
You have to compare the input value from the database

if <Report."event.cfTime"> = '00:00' then ...

But such a procedure can lead to hiding several values in the line in the MasterData.
The best solution would be.
In the time field, enter

[StrToTime (<your field from the database>)]

Select Time format hh:mm to not display seconds.
In the field properties set HideZeros - True.

Post's attachments

Attachment icon capt.jpg 126.94 kb, 143 downloads since 2021-11-03 

3 (edited by derek 2021-11-03 12:10:37)

Re: [SOLVED] Hide a Memo field

Hi Joshua, Hi Sparrow,
An option that I've used before for something similar is:
1.  Use stfrtime in a calculated field to format the time to hours and minutes (no seconds) and display this in the tablegrid.
2.  Take the calculated field across to FastReport
3.  Use the memo field 'highlighting' option and test for 00:00 and, if so, set the colour to be clwhite (see screenshot in the attachment).
Derek.

Post's attachments

Attachment icon hide time.zip 493.62 kb, 273 downloads since 2021-11-03 

Re: [SOLVED] Hide a Memo field

Hi Derek,

Condition in highlight. Nice.

Re: [SOLVED] Hide a Memo field

Hey sparrow and derek,
.
As always thank you for the suggestions!
.
derek is all about those calculated fields lol  I was experimenting with that approach as well, but I couldn't get it working.  Forgive me for not throwing together an example solution for the question.  And MANY thanks for providing us one here!
.
I was able to get both of your methods to work, but I had to do some minor adjustments with sparrow's code because it kept throwing an error about the report field not being a valid time.  I don't fully understand the syntax in FastReport with the brackets <> and [] and ().  Because of this, I get unexpected results usually.  Anyways- I managed to get it working.
.
I really appreciate it guys!

"Energy and persistence conquer all things."

6 (edited by joshuA 2021-11-04 01:00:15)

Re: [SOLVED] Hide a Memo field

This is the result from (the next step in) my project since I didn't post one for this question...  I went back and adapted the project for this post from another thread.
.
Everything is working perfectly, but I have another very minor question (mainly just out of curiosity).  I'm using mm/dd for the dateTime format in the report, but it's showing mm-dd instead.  My guess is that it's using the Regional format settings from the PC for this.  Is there a way to force a slash / instead of the dash - for this case?
.
[edit]always forgetting to attach the file tongue[/edit]

Post's attachments

Attachment icon 7826_attendance-v3.zip 338.79 kb, 275 downloads since 2021-11-04 

"Energy and persistence conquer all things."

7 (edited by derek 2021-11-04 01:29:42)

Re: [SOLVED] Hide a Memo field

Hi Joshua,
Well, I guess you know what I'm going to suggest - LOL!
In the attachment, all I've done is create a calculated field (cfadate) based on 'attendance.adate', use strftime to force the character that you want to use to delineate between month and day (I've used a '*' just as a test) and then take it across to FastReport.
And yes, it is the regional date/time settings of the PC that are used in FastReport if you use a date/time field.
Derek.

Post's attachments

Attachment icon 7826_attendance-v3.zip 350.4 kb, 288 downloads since 2021-11-04 

Re: [SOLVED] Hide a Memo field

Thanks again cfDerek cool
.
Up until a few minutes ago, I thought I solved it using sparrow's steps.  But it turns out that I was using a different PC, and evidently the date formatting on that PC uses a slash / as the date separator (so I thought it was fixed), and on this PC it's using the dash - instead.  However, this is a tedious detail that I wanted to point out.
.
So the cfField is the best way to fully control the formatting here.  It's kinda interesting that FastReports ignores the special formatting characters explicitly defined within one of its own field's property settings though.  But, I guess this falls into one of those controlling the interface arguments. roll
.
I'm starting to see now-  the reason for your new nickname. lol

"Energy and persistence conquer all things."

Re: [SOLVED] Hide a Memo field

Hi Joshua,
I'm not saying it can't be done in FastReport (and as you say, you'd think it should be possible with all its options). 
Perhaps someone can shed some light on it?
But I've never got properly to grips with FastReport (my fault), so I've always tried, if possible, to do most of the heavy-lifting in MVD itself where I feel more at home!
Derek.

Re: [SOLVED] Hide a Memo field

cfDerek,
.
Yeah- I didn't mean to imply that the calculated field was the only way.  But at this time, it has been the only suggestion that solves this sub-request.  It's not really an issue, maybe just a minor nuance.
.
I guess I was merely saying that I understand why you choose to stick with the cfFields (that work using MVD) rather than in FastReport.  Because they do EXACTLY what we intend for them to do, regardless of the behavior that the user's OS is defaulting to.  (which in most cases, they aren't even aware)
.
But again I would like to say that I can understand both sides here.
.
Thank you once again and many more. :salute:

"Energy and persistence conquer all things."