Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SCAN ..... ENDSCAN
Message
 
 
To
21/06/2001 03:01:07
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00521771
Message ID:
00521849
Views:
15
>Hi all again,
> I'm doing some computations on a records in a table using the SCAN ... ENDSCAN. I have a variable (var1) which stores the compound number (1, 2, 3,..) and var2 (1, 2, 3,..) which stores the house number. Var2 is incremented by one from the previous record if the compound is the same otherwise var2 starts from one again. I was wondering if there's a function in VFP6 that can lag values (something like the LAG() function in SAS!). Or how do I go about this? I want my code to "see" the previous value of compound (var1) and/or house (var2).
>
>Thanks in advance guys.
>Richard.

Let's say you have another fields called Base, and within Base, you can have multiple occurrences of different compounds.
Base    Compound   House
----    --------   -----
1           1        1
1           1        2
1           1        3
1           1        4
1           2        1
1           2        2
1           2        3

2           1        1
2           1        2
2           1        3
2           2        1
2           2        2
2           2        3
2           2        4
What I would do is create 2 parameterized views, and requery them as needed
create sql view lv_max_compound as select max(compound) Compound ;
   from mytable where base = ?nBase

create sql view lv_max_house as select max(house) House ;
   from mytable where compound = ?nCompound
When the Base and/or Compound changes or after adding a new record [and updating any buffered changes], all you have to do is:
nBase = mytable.base
nCompound = mytable.compound
requery('lv_max_compound')
requery('lv_maxhouse')
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform