Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Many to 1 page
Message
From
09/09/2015 01:50:08
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
 
 
To
08/09/2015 22:54:03
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01624384
Message ID:
01624386
Views:
88
>I cannot remember how years ago I used to do the following:
>
>I have a cursor with X records, let's say 50. The report form needs to be 1 page exactly to fit a government mandated format. Each of those 50 items will appear somewhere on the page, depending on 3 fields contents. I cannot crosstab it.
>
>It is NOT a multi-band report. Each field on the report form could pull its data from anywhere within the 50 records, and there is no logical sorting that could put them in any sensible order. As each field on the report has to retrieve data, it has to check 3 fields and if matchs 3 fields write the value of a fourth field.

You could use a UDF:
FUNCTION MyUDF

LPARAMETERS ;
    SourceColumnName ;
    , TestFieldVal1 ;
    , TestFieldVal2 ;
    , TestFieldVal3

LOCAL ;
    lnSelect ;
    , luRetVal

m.lnSelect = SELECT( 0 )

SELECT ;
    SourceColumnName AS MyResult ;
    FROM MyCursor ;
    WHERE TestField1 = TestFieldVal1 ;
        AND TestField2 = TestFieldVal2 ;
        AND TestField3 = TestFieldVal3 ;
    INTO CURSOR Result

m.luRetVal = Result.MyResult

USE IN Result

SELECT m.lnSelect

RETURN m.luRetVal

* The expression for each report field would be a MyUDF() call.

* The above is fairly general. If you have only one column in your report source cursor then you wouldn't have
* to pass the column you want to seek in. You could delete the SourceColumnName parameter
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform