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

How to change font type on a report when a particular condition applies 4

Status
Not open for further replies.

Steve-vfp9user

Programmer
Feb 5, 2013
334
0
16
GB
Hello

I recently resolved my problem on thread (thank you)

This is a follow on from that thread and would like to know how to change font type using "Print when" or other method on a report when a particular condition applies.

I am aware of examples in the controls properties section such as:

Print only when expression is true: not empty(mydate)
or
Print only when expression is true: mynumber>0

One field in my table COSTMASTER is called CATYPE and it is that field the word INVOICE is shown in some records

The default font for that field is: Arial, Regular, 8

If the word INVOICE is in the record, how do I change the font to something like: Arial, Bold, 10

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
There are no DynmicFontBold or other dynamic properties of report controls like these exist for grid columns, for example. and while VFP9s report engine (90) has some advanced features like printing rotated text, and colors, that hasn't changed. I think there was some project in VFPX that allow usage of HTML style tags, which means you can mix bold and non-bold and some other font modifiers.

But what you already know can also be used with fixed font layouts. You just need two report controls or labels you position at the same place in the report, one prints when At("INVOICE",catype)>0, ie INVOICE is within the field, and one that prints when At("INVOICE",catype)=0, ie when INVOICE is not in the text. So alwayys one of the two controls print, the other doesn't. That spares you creating two reports.

Besides, you could simply have a logical field within the report data that tells that difference for the print when condition, which also makes you independent from the exact word, just decides the two layouts that way.

So all in all it just means positioning two things at the same position, you can easily do that by selecting the second one and using the arrow keys to move it at the same position.

Chriss
 
Chriss is right about 'overlapping' elements and setting them to have mutually exclusive 'print when' conditions.

This can get a bit complicated when there are many items one the same line - so to speak - but if you just have
a single line with two possible conditions for a single element like Credit Note or Invoice, you can combine the
'print when' with a 'remove line if blank' and position the two elements one above the other vertically (not in the z axis)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Chriss, Griff

I’ll try out your suggestion

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
Steve,

While editing the COSTMASTER.CATYPE field properties, select the Dynamics tab and add a new condition (for instance, "IsInvoice").

Set the condition and adjust the font to your requirements. For instance:

Captura_de_ecr%C3%A3_2023-08-24_070434_dqrp0k.png
 
Yes, the way Antonio describes it is the same way I do it when I only need to change the font size or color dynamically. Notice that you can also make the font bold by changing the font itself (there is no checkbox for the "bold propterty" like on a form).

When changes need to be more complicated, like a different position, alignement, size of the field, using a second textbox and the "print when" option is the easiest way.

You can also dynamically change the report before issuing REPORT FORM during runtime by using the report like a table:

USE myreport.frx

Then you can change the record corresponding to the specific control you want to change. You can add a comment first to the control (in the field properties click on the "Others" tab) to be able to identify the record of the control later on by locating for the record which contains your comment. I find this document very helpful in understanding the structure of the report-dbf-file:


But this is kind of advanced and not needed in most cases.

Regards,
Manni
 
I realize what atlopes posts is in fact the dynamicXYZ I said is only available in grid columns. I forget they integrated it into the VFP9 report engine. Just notice you need to SET REPORTBEHAVIOR 90 to let this work at all.

Chriss
 
atlopes

I tried your suggestion but the font didn't change. I also change the SET REPORTBEHAVIOR TO 90 as Chriss suggested but still no effect.

I then tried out the overlapping putting a duplicate field over the top of the original, changed the field font settings and added the condition to the "print when...."

This has now resolved my question.

I will however have a look at why perhaps the Dynamic Properties suggested by atlopes didn't work in my case, I never knew about that function.

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
Steve, after adding a dynamic property, make sure, that "Print when" is empty, in case you have experimented with this option before. Also double check in the menu of the dynamic property if the condition you entered in "Apply when this condition is true" is really true before you report the form (i.e. first use simply .T. for test purposes) and that the field "Replace expression result with:" is empty. It should work, I've used it many times.

Regards,
Manni

 
Mannib

Thank you for your post

Mike

I think António's suggestion depends on having SP2 installed for VFP 9.

If you look at my footer profile, I have SP2 installed!

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
1. The command to use is SET REPORTBEHAVIOR 90 not SET REPORTBEHAVIOR TO 90
2. When you want your EXE to be able to use the VFP9 report engine you must also provide the report engine APPs, at least the ReportOutput.app

In general, consult the FoxPro help file about the new VFP9 report engine to make use of it. If you don't you fall back to the legacy report engine of VFP8 or lower, as 90 report engine is not embedded within the vfp9r.dll runtime.

Chriss
 
Chriss

The "SET REPORTBEHAVIOR TO 90" was a typo. I just checked my PRG and it is set to "SET REPORTBEHAVIOR 90" but thanks for pointing that out.

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
Steve,

there could always be an error handler just logging errors and not showing them. But then again, the second point is more important. If you don't run with the reportoutput.app present and set in the _reportoutput system variable you only run with legacy report features and whatever you configure in terms of danmic properties is ignored without any error, even when you SET REPORTBEHAVIOR 90. So that is more important. I suggested you read about the new report engine in the help file, it has all details you need to know to use it, both within the IDE and deployed with an EXE.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top