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

String to be printed with portion of string to be in bold 1

Status
Not open for further replies.

mayuso

Programmer
Jun 16, 2003
8
BZ
I have a report that need to print 5 possible fields varchar(200) which are comments within my application. Within my report I include a label bold and beside it I place the field. I go down the report and end up with all 5 fields each having a label in bold. My problem with this is that it takes up unnecessary space within my report if one of my fields is blank and have spaces in between lines between the fields or the entire content of the fields are not displayed in the print out.

Because of this I concatenate all 5 fields and labels in one variable each having a carriage return so it looks nice. This works good and it does not use up space. However, I cannot bold the labels within the text of the each label.

For example.
Remarks: The quick brown fox jumped over the lazy dog's tail with ease.
Incidents: blank
Complaints: There is too much fat within the team..
Recommendations: Streamline the workforce by doing interviews
Delays: The truck had an oil leak

I use the variable Print_Comments to store the content.

Code:
	Print_Comments = ;
		IIF(!EMPTY(alltrim(ShipWork.Comment_Delays)),'Delays: '+alltrim(ShipWork.Comment_Delays)+chr(13),'')
	Print_Comments = Print_Comments + ;
		iif(!empty(alltrim(ShipWork.Comment_Complaints)),"Complaints: "+alltrim(ShipWork.Comment_Complaints)+chr(13),"")
	Print_Comments = Print_Comments + ;
		iif(!empty(alltrim(ShipWork.Comment_Incidents)),"Incidents: "+alltrim(ShipWork.Comment_Incidents)+chr(13),"")
	Print_Comments = Print_Comments + ;
		iif(!empty(alltrim(ShipWork.Comment_Improvements)),"Remarks: "+alltrim(ShipWork.Comment_Improvements)+chr(13),"")
	Print_Comments = Print_Comments + ;
		iif(!empty(alltrim(ShipWork.Comment_Recommendations)),"Recommendations: "+alltrim(ShipWork.Comment_Recommendations)+chr(13),"")

I want my report to print like this:
Remarks: The quick brown fox jumped over the lazy dog's tail with ease.
Complaints: There is too much fat within the team..
Recommendations: Streamline the workforce by doing interviews
Delays: The truck had an oil leak

where "Remarks:", "Complaints:", "Recommendations:", and "Delays:" to be bold

I am not sure if this is possible or if there are alternatives within the report designer itself. Please help.

Regards,
Mike Ayuso
 
Mike, there is no easy way of doing this. Given that you have the entire text, including the labels, in a single field, you can either format the entire field in bold, or the entire field as normal, but not a mixture of the two. VFP's report designer does not natively support "rich text".

But, going back to the beginning, you say the problem is that you don't want to waste space if a given field is blank. In that case, you can use Print When to suppress the label. So, for "Print only when expression is true", the expression would be something like [tt]NOT EMPTY(MyField)[/tt]. (You would put that expression in the label, not the field.)

You can then tick "Remove line if blank", and the entire line will be suppressed - so no wasted space.

Of course, this assumes that there is no other data anywhere else on that same line. If that's not the case, you would need to adjust the design of the report.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks for the reply.

I originally had my report as your second suggestion where I have all 5 fields and I did have the condition only to print if not empty. That was working fine. But then I came across the issue when one of the fields are longer. For example. I have all 5 field properties stretch with overflow in the event the content is long. That works okay. But the labels I have on the left of each field within my report, is not aligned with each respective field.

Eg:

Code:
Delays:		11111111111
	
Complaints:	22222222222222222
		222222222222222
Remarks:	3333333333333333333333333333
		3333333333333333333333333333
Recommendations:33333333333333333333
		333333
		44444444444444444444444
		4444444

You can see where the label Recommendations is not in the same line as the 444444....
Also you will notice there is a blank line between Delays and Complaints. This is because the field properties height are set to 0.312 in.

I had all labels and texts OBJECT POSITION to FLOAT

 
 http://files.engineering.com/getfile.aspx?folder=5fb4af16-d2aa-4979-a12d-12f81641255d&file=Untitled.jpg
To let the memo overflow push down the left side labels, too, add a line element across the whole page width and this will push down the right hand control and the left hand label, even if you set the line element to printwhen=.F. (never print). This way you have an invisible element pushing down labels, too.

See here:
reporttrick1_yx06xk.png

I just styled the line element red to highlight it.

reporttrick2_uv6w4u.png

Memo1 pushes down the invisible line element and that pushes down both Label2 and memo2.

Bye, Olaf.
 
Mike said:
Mike, there is no easy way of doing this. Given that you have the entire text, including the labels, in a single field, you can either format the entire field in bold, or the entire field as normal, but not a mixture of the two. VFP's report designer does not natively support "rich text".

I wrote something a long time ago on using an RTF control in a FoxPro report.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Olaf,

This worked perfectly well. It took me a while but got through. I added the invisible lines as you suggested along with having the left labels as Object Position as Float and all fields in the report as Float and Stretch with Overflow. It comes out perfectly well. Many thanks again. Visual FoxPro Rocks!!!
 
I should have added that all the elements should be set to float. Obviously the topmost elements can be fixed to the top of the band, but fixing other elements to top or bottom does not make them react to previous element pushing them down, that's only happening to floating elements, that's what floating means, you float away to make place for any elements above and of course also push down floating elements further below. There have to be stretching elements to start this process, of course and all the variable height memos should stretch with overflow.

Your initial problem simply was, that there are no elements above the floating labels, which made them quasi fixed. A full band width line is a little tricky helper, but I'd not say it's elegant or rocks. If you ever used other reporting engines you'd miss features in VFPs, even though there are some advanced features the reports are my least favourite VFP feature.

Bye, Olaf.
 
Hi Olaf,

I totally agree with your comments. Out of curiosity, you say "other reporting engines". I mostly use the report design from VFP9 itself, and on some other projects I also use FoxyPreviewer.App to control my output to Excel, and PDF, etc. Which by the way this same report works well with FoxyPreviewer.App. What other reporting engines might there be that can be incorporated with my VFP project?
 
Favorite engines used by VFP developers are

Fox related:
FoxyPreviewer
XFRX-extending FRX capabilities
FoxFire

Non fox related:
List&Label
Crystal Reports

Bye, Olaf.
 
I forgot the fox related Report Sculptor and of course SQL Server Reporting Services, once you put your data into the MS SQL Server.

Bye, Olaf.

 
Thanks for the info. Very useful! Although I was only familiar with FoxyPreviewer, and Crystal Reports, I am looking at these for sure. Although I mostly use MySQL and MS SQL to store my data depending on my projects, I will also look at the MS SQL Report Services, which I have seen but never used it. I am sure each of the ones you mention have their strengths. :)

 
You can also use RTF via Richtext control, but it's nicer to be able to use HTML, as there is much more HTML available and the capabilities are beyond what RTF offers. So this is a welcome Foxypreviewer feature.

Anyway, in this case keeping labels and texts separate was the more natural solution and the only problem to solve was how to stretch and float elements, especially how to float down the labels. I don't see FoxyPreviewer adding to this float dependency of separate report elements. You would need extended properties, like linking/anchoring elements to stay in same height. Another layout solution would be putting labels above the memo fields, labelling a longer text above it also is a normal layout.

And in the above html example, either the [sup]superscript[/sup] tag/style is wrong or the text should read striked.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top