Topic: Report items change
Dears
I get the days of the week as numbers in a table, can I change them in the report designer to the names of the days and how ?"
Thanks again
My Visual Database → General → Report items change
Dears
I get the days of the week as numbers in a table, can I change them in the report designer to the names of the days and how ?"
Thanks again
Allega il progetto per poterti aiutare meglio!
Here is the example: there are (days of week ) represented as numbers, and I want to display them as the names of the days in the report
You can use a calculated field like
CASE <FIELD Name>
WHEN 0 THEN 'Sunday'
WHEN 1 THEN 'Monday'
WHEN 2 THEN 'Tuesday'
WHEN 3 THEN 'Wednesday'
WHEN 4 THEN 'Thursday'
WHEN 5 THEN 'Friday'
WHEN 6 THEN 'Saturday' END
or in the FastReport script like
begin
case <variable name> of
1: Form1.Edit1.Text := 'Sunday';
2: Form1.Edit1.Text := 'Monday';
3: Form1.Edit1.Text := 'Tuesday';
4: Form1.Edit1.Text := 'Wednesday';
5: Form1.Edit1.Text := 'Thursday';
6: Form1.Edit1.Text := 'Friday';
7: Form1.Edit1.Text := 'Saturday';
end;
end;
In addition, Pascal and SQLite have their own functions for determining the day of the week (day number) by date.
DayOfWeek()
And
strftime('%w', ...).
thanks
but the numbers in the table already
the Fast report code never worked with me , can someone explain how to me ???? or modify the sample that I have add pleaseeeee ?
i want to know why it never worked for my
Hi Samtom, Hi Sparrow,
Personally, I would probably use a calculated field as suggested by Sparrow.
However, if you are not yet familiar with how to create a calculated field, another option is to hold the days of the week in a look-up table (see attached).
You also need to be careful viewing and creating records on the same form (Form1); it is very easy to inadvertently create duplicate records if you have not added a bit of 'script' to prevent this.
Derek.
Thank you very much, dear Derek. You are always our savior
I have another question: Do you have an example of changing data in FastReport? I've tried this many times but always encounter errors. I want to understand the mechanism, and if you also have an example of a calculated field, that would be great. )))
To use a calculated field:
1 create a new field in your table with a field type of 'calculated field'
2. add the code (exactly as already detailed by Sparrow)
3. display the calculated field in the tablegrid (optional)
4. add the calculated field to the field selections in the 'report' action.
5. the calculated field can be referenced in 'FastReport' like any other field type.
Have a look at the attachment and the included screen shot.
Derek.
To add the 'day of the week' as text in FastReport directly, you could
1. add a memo field and place it on the report layout (see the screenshot in the attachment).
2. create a 'before print' event for the Master Data band (see the screenshot in the attachment)
3. insert the code that Sparrow gave you in a previous post or use the code already there (see attachment).
There may be other (better) ways to do this - I don't use FastReport very much so I'm probably not the best person to ask.
Derek.
Hi Derek,
Thank you.
samtorn, for self-study.
Option for FastReport. Directly for the Memo field on the form.
Create Memo2 next to Memo1 in Derek's example and place the code below.
It looks scary but it's simple.
[IIF(<Report."Employer_Hours.dayofweek">=1,'Mon',
IIF(<Report."Employer_Hours.dayofweek">=2,'Tue',
IIF(<Report."Employer_Hours.dayofweek">=3,'Wed',
IIF(<Report."Employer_Hours.dayofweek">=4,'Thu',
IIF(<Report."Employer_Hours.dayofweek">=5,'Fri',
IIF(<Report."Employer_Hours.dayofweek">=6,'Sat',
'Sun'))))))]
OR
[SQLExecute('SELECT CASE '''+<Report."Employer_Hours.dayofweek">+'''*1 WHEN 1 THEN ''Monday'' END ')]
And a link to the manual to make it work: https://www.fast-report.com/public_down … ual-en.pdf
My Visual Database → General → Report items change
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi