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

I thought this would work but it wo

Status
Not open for further replies.

wesleycrusher

Technical User
Sep 30, 2003
61
US
I thought this would work but it won't. I want to add the contents of the field to a string declared variable and separate the results with a comma. Please let me know what is wrong with my syntax if this is even possible (no reason it shouldn't be).

I have the IF-THEN statement twice+ because it is possible for there to be more than one trade name associated with a model number. I am not sure how to have it cycle to find all of them so I can add them to the string. This is also something I would appreciate any insight on.

Thanks!




stringVar tradename := {trade_name.trade_name};

If {furnace_model.model_number} In "{trade_name.trade_name}" Then tradename:= +{trade_name.trade_name} +",";

If {furnace_model.model_number} In "{trade_name.trade_name}" Then tradename:= +{trade_name.trade_name} +",";

If Length(tradename) > 0 then Left(tradename, Length(tradename)-1);

 
I think this is what you are looking for...

stringVar tradename := {trade_name.trade_name};
If {furnace_model.model_number} In "{trade_name.trade_name}" Then tradename:= +{trade_name.trade_name} +",";
ELSE If {furnace_model.model_number} In "{trade_name.trade_name}" Then tradename:= +{trade_name.trade_name} +",";
ELSE If Length(tradename) > 0 then Left(tradename, Length(tradename)-1);
 
Having it twice doesn't make sense, if you have more than one value then the next row will add it to the variable.

Try:

In a section before the details (if you're not grouping data you won't need this):

stringVar tradename := "";

Details section:
stringVar tradename;
If {furnace_model.model_number} In "{trade_name.trade_name}" Then tradename:= tradename+{trade_name.trade_name} +",";

After the details section to display the combination:
Display section:
stringVar tradename

-k
 
You have a few fundamental flaws in this formula...MJRBIM
has not addressed them

I have the IF-THEN statement twice+ because it is possible for there to be more than one trade name associated with a model number. I am not sure how to have it cycle to find all of them so I can add them to the string. This is also something I would appreciate any insight on.

First of all a formula only acts on one record at a time so doing the way you showed would actually add the same value of {trade_name.trade_name} to the string each time it was run.

You have not outlined the structure of your report (you should always do this) but I am assuming that you only want this to be run for a given Group...if not advise how this is supposed to go....the "crystal" ball is weak from this side of cyberspace :)

So proceeding on that assumption...

create an initialization formula to be placed in the Group header (suppressed) that you want repeat values to be added

*********************************************

//@initialization

whilePrinitingRecords;

if not inRepeatedGroupHeader then
stringVar tradename := "";

*********************************************

Now in the detail section or a group header for {trade_name.trade_name} place the following formula

*********************************************

//@create_tradename (suppressed in whatever section)
WhilePrintingRecords;
stringVar tradename;

If {furnace_model.model_number} In {trade_name.trade_name}Then
tradename:= tradename + {trade_name.trade_name} +",";

*********************************************

Now create a display formula to show the resulting value

*********************************************

//@create_tradename (placed in the footer where you want the results shown)

WhilePrintingRecords;
stringVar tradename;

If Length(tradename) > 0 then
tradename := Left(tradename, Length(tradename)-1);

"This is the value: " + tradename;

the only thing to be carefull of is if the value of "tradename" can exceed 254 characters...it doesn't seem possible here...but if you are adding several (more than 2) of these together then you will have to watch for it in the formula.

hope this helps



Jim Broadbent
 
Sorry for not outlining the situation well enough, I try to keep it short and sweet. I posted last week with a better description of what I am trying to do. I believe the thread was titled "Grouping Groups". For more info, please red that. Essentially I am grouping models by trade name but there is a lot of overlap. I am trying to dynamically read which trade names apply to model numbers and group on that. I hope to be able to group by a formula that will also handle the title of the groups as well.

Hope this helps.
 
well what I have outlined will display a result....however it is not possible to group on this formula because it is processed during the running of the report (ie. after all the grouping has been done)

I cannot help any further sorry

Jim Broadbent
 
Ngolem,

Is it possible to create a "dummy" subreport that will process before running hte report?
 
certainly...a subreport can be run in the report header

however, I doubt you can group the main report based on the results of the subreport

Jim Broadbent
 
That's called wasting time, not short and sweet.

Consider posting in links to related posts, or at least provide the same level of detail, this post was anything but short and sweet.

Grouping on groups makes no sense, a group is already distinct, if you group on them, you'll get the exact same rows. What you wanted was to derive groups based on one field existing in another.

I vaguely remember your original post, and it seemed as if people had offered solutions, try finding it yourself and rereading them.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top