Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP7, CR9, UFLs, OLEDB and migranes
Message
 
 
To
13/12/2002 12:59:01
James Hansen
Canyon Country Consulting
Flagstaff, Arizona, United States
General information
Forum:
Visual FoxPro
Category:
Crystal Reports
Miscellaneous
Thread ID:
00731935
Message ID:
00733252
Views:
42
I had the same problem.
I do not make any more a UFL.
I make a function in my * DBC.
Example
FUNCTION Age(ddate)

Connection ODBC Return my function

Select Name, Firstname, Age(Employee.Dnaissance) From Employee.....



For the Name of compagny, I make Calculed fields.
{@CompagnyName}
>>
 PROCEDURE SetFormulaValues
      *---------------------------------------------------------------------------------------------------
      *      LPARAMETERS cFormulaName, xValue

      LPARAMETERS cFormulaName, xValue, oSubReport
      *
      * Purpose:	Set the specified value of a Crystal Report formula to the specified value
      *			This could be as simple as setting a report title.  It could also be used to
      *			tell the report to only look at a certain subset of records in the dataset.
      *			See the Customer.rpt for a sample.
      *
      * cFormulaName			Name of formula we want to set
      * xValue				Value to set - could be any datatype supported by CR8.5
      *
      * ASSUMES:
      *	crReport			Valid Crystal Reports Report Object
      *
      * RETURN VALUES:
      *	.T.			Formula value set successfully
      *	.F.			Formula value not set - most likely cause is misspelled formula name
      *
      * Is the formula name specified with a leading '@' sign?
      *
      *---------------------------------------------------------------------------------------------------
      LOCAL x, lFound, cValue , nHour , cHour , cMinute , cHeure , ovReport

      *-- Milcent b 09/2002.
      IF VARTYPE( oSubReport ) = "O"
         ovReport = oSubReport
      ELSE
         ovReport = THIS.crreport
      ENDIF


      cFormulaName = '{' + cFormulaName + '}'

      lFound = .F.
      cValue = ''

       WITH ovReport.FormulaFields
         FOR x = 1 TO .COUNT
            IF ALLTRIM( UPPER( .ITEM( x ).NAME ) ) = cFormulaName
               lFound = .T.
               EXIT FOR
            ENDIF
         ENDFOR
         IF lFound
            *
            * Massage the value based on type
            *
            DO CASE
               CASE VARTYPE( xValue ) = 'C'
                  *-- Milcent b. 08/2002.
                  *-- To cut " or ' Because it give a error IN CR.
                  *!*   xValue = STRTRAN( xValue , '"' , ' ' )
                  xValue = STRTRAN( xValue , "'" , ' ' )

                  cValue = "'" + xValue + "'"
                  *cValue = '"' + xValue + '"'


               CASE VARTYPE(xValue) = 'D'
                  SET DATE AMERICAN
                  cValue = "#" + DTOC(xValue) + "#"
                  SET DATE FRENCH
                  *cValue = "CSTR(" + DTOC(xValue) + ", 'dd mm yyyy' )"

               CASE VARTYPE(xValue) = 'T'
                  SET DATE AMERICAN
                  * cValue = "'" + TTOC(xValue, 1) + "'"
                  *cValue = "#" + TTOC( xValue , 1) + "#"

                  nHour = HOUR( xValue )
                  cMinute = ALLTRIM( STR( MINUTE( xValue ) ) )

                  IF nHour > 11
                     cHour = ALLTRIM( STR( nHour - 12 ) )
                     cHeure = "pm"
                  ELSE
                     cHour = ALLTRIM( STR( nHour ) )
                     cHeure = "am"
                  ENDIF

                  cValue = "#" + DTOC( TTOD( xValue ) ) + " " + cHour+;
                     ":" + cMinute + " " + cHeure + "#"

                  SET DATE FRENCH

               CASE VARTYPE(xValue) = 'N'
                  *-- Bug 11/2002
                  *-- On peut avoir 1 Numéric à Virgule !
                  *-- Même raisonnement que 'Y'.
                  IF MOD( xValue , 1 ) = 0
                     cValue = xValue
                  ELSE
                     * cValue = "'" + STR(MTON(xValue), 15, 2) + "'"
                     cValue = INT( xValue )
                  ENDIF

               CASE VARTYPE(xValue) = 'Y'
                  cValue = "'" + STR(MTON(xValue), 15, 4) + "'"

               CASE VARTYPE(xValue) = 'L'
                  cValue = IIF(xValue, 'True', 'False')

               OTHERWISE
                  =MESSAGEBOX('Unrecognized type: ' + TYPE('xValue'), 0, 'SetFormulaValues  ERROR')
                  lFound = .F.

            ENDCASE
            .ITEM(x).TEXT = cValue
            *!*	         ELSE
            *!*	            =MESSAGEBOX('FormulaName ' + cFormulaName + ' not found in this report', 0, 'SetFormulaValues Error')
         ENDIF
      ENDWITH

      RETURN lFound
   ENDPROC

 
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform