Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you call a METHOD from a report to get a variable?
Message
De
02/02/2007 12:32:06
Peter Brama
West Pointe Enterprises
Detroit, Michigan, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows '98
Divers
Thread ID:
01191362
Message ID:
01191879
Vues:
8
>>>>I am trying to get some specific calculations off of items sold in a POS system and print them on a report. Unfortunately, because these calculations vary greatly on several factors... it would be next to impossible to put them in the small EXPRESSION field in the report writer itself. In addition, trying to store them in temporary variables during the actual criteria step of the report call would be nearly impossible as well... to many factors control what needs to be calculated.
>>>>
>>>>I can write the actual calculations in a couple of code snippets and want to know if there is a way to call that coded routine from the actual report and have it return to the report the final calculation for printing.
>>>>
>>>>Thanks ahead of time.
>>>
>>>To expand Ed's solution. Put a textbox on the form with expression MyFunction(). Let your function to return empty string. Add remove if blank option to this textbox.
>>
>>
>>Thanks everyone... this worked just fine. I created a function, pass it the amount to base the calculations off of, and it returns the correct fees which print on the report.
>>
>>One more related question... is there a way to SUM the returns from this function so we can put a total at the bottom of the report?
>>
>>Thanks again...
>
>Looks like this has to be done through report variable. Then Don's warning may apply. In other words, you would need to have a report variable and the value to assign would be result of your function. You can check SUM in the calculations.


Not sure if this a "clean" way to do it, but I got it to work this way.
- Created a report variable called totfee
- Have the regular field that prints the return from the function as normal
- Created an extra field at the end of the detail band that has the function call again like this: totfee=calcfees(amt) I have the PRINT WHEN set to .T.=.F. so nothing prints

By doing this, I have a report variable I can subtract from another total to the adjusted amount at the end of the report.



One more question... when I try to format the return from the function to get a currency figure... it gets all messed up. For other fields in the report, I have them set for NUMERIC/CURRENCY and use a format of $$,$$$.99. They look fine. For the one with the functionc all, if I do this, I get ******. If I remove the format string altogether and use the @$ I get $1.7695 With my limited knowledge, I think it might be that the return is coming back from the function possibly as a string????


Once again... thanks, you all are the best...


Thanks again...
Peter Brama
West Pointe Enterprises

VFP is getting easier but STILL alot to learn!!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform