Thursday, June 12, 2008

VFP Reporting Tip - paying it forward

I was mentoring one of our clients this morning because of a reporting issue he faced with some weird truncating labels (not that this tip is of any help for his problem {g}). During the session he showed me this new wiz-bang function he created to concatenate text together to be displayed on the report. He mentioned how his function removes the missing details from a snail mail address. You know the drill, customer wants to track address line 1 and 2, contact name and company name, but only wants to print the things that are filled in.

I turned around and told him about his new friend the semi-colon (;). This is a trick I learned back probably in FoxPro for Windows or even DOS when I was creating labels for customer mailings. You first drop a textbox on the Report/Label designer and size it to show the max lines you will print based on all the data being entered in the record. You can add the expression like this:

cCustomerName;cCompany;cAddress1;cAddress2;ALLTRIM(cCity)+",",cState,cPostalCode;cCountry

The semi-colon acts as a carriage return and any columns in the expression that are empty are not printed and if the line is empty the carriage return is not included. The commas (,) outside of a quote are replaced by spaces. So you can see how I am concatenating the city, state, and postal codes for a line.

I know this is an old trick and tip, but my client has been using Fox of some sorts for a long time too so in the case where you did not know this I am hoping it will be helpful. There are so many little things like this I take for granted that everyone knows, but realize in working with other Fox developers that this is not always the case. I also wonder from time-to-time how many little tips like this one I don't know about.

Labels: , ,

6 Comments:

At 6/12/2008 10:15:00 PM, Anonymous Cesar said...

This is an old trick ?
Well, super new for me :-D
I owe you a beer for that !
Thanks !

 
At 6/13/2008 06:51:00 AM, Blogger Rick Schummer said...

Thanks for verifying my point Cesar. You are welcome, and virtual lemonade would be fine. {g}

 
At 6/13/2008 12:03:00 PM, Blogger Rick Borup said...

Oh, man, I've been working with Fox for 15++ years and I did not know this. Thanks, Rick.

 
At 6/17/2008 06:45:00 PM, Blogger Craig Bailey said...

Yep, add me to the list.
That's a new one for me too.
Thanks Rick.

 
At 7/24/2008 06:54:00 PM, Anonymous Alan said...

That is very cool. I've been playing with fox since the mid 80's and never knew that.

 
At 6/23/2009 02:10:00 PM, Anonymous Anonymous said...

I have been fighting address since foxbase and have never seen any reference to this trick.
Thanks Rick
Jerry Foote

 

Post a Comment

<< Home