Hi: I need to validate that records have been entered correctly in a
table, by correctly I mean in ascending order. But with a small
variation, the first record can have any value, so:

Field1
100
2
3
4
5
6

This is correct, because record 1 can have any value, but :

Field1
88
2
3
7
5
6

Is wrong, can I validate this using VFP?

Re: Validating data, tricky one... by Anders

Anders
Tue Sep 18 14:59:35 PDT 2007

It might be easier to create this table as a cursor with a query:
Here's an example
CREATE CURSOR xx (num int)
INSERT INTO xx VALUES (88)
INSERT INTO xx VALUES (1)
INSERT INTO xx VALUES (4)
INSERT INTO xx VALUES (3)
INSERT INTO xx VALUES (2)

CREATE CURSOR x1 (number int)
INSERT INTO x1 (number) SELECT num FROM xx WHERE RECNO()=1
INSERT INTO x1 (number) SELECT num FROM xx WHERE RECN()>1 ORDER BY num
SELECT x1
BROWSE LAST NOWAIT

Or put them into an array and sort the array starting with element 2 using
ASORT
SELECT * FROM xx INTO ARRAY aX
ASORT(aX,2,-1,0)
CREATE CURSOR x1 (number Int)
INSERT INTO X1 FROM ARRAY aX


BTW, it's rule #1 of relational tables that the order of rows and columns is
without importance. Don't try ands build a data kingdom on these kind of
table specifications.

-Anders



"Texeira" <eugenio.grant@gmail.com> wrote in message
news:1190150174.048566.244590@19g2000hsx.googlegroups.com...
> Hi: I need to validate that records have been entered correctly in a
> table, by correctly I mean in ascending order. But with a small
> variation, the first record can have any value, so:
>
> Field1
> 100
> 2
> 3
> 4
> 5
> 6INSERT INTO
>
> This is correct, because record 1 can have any value, but :
>
> Field1
> 88
> 2
> 3
> 7
> 5
> 6
>
> Is wrong, can I validate this using VFP?
>



Re: Validating data, tricky one... by Rush

Rush
Tue Sep 18 15:04:58 PDT 2007

Texeira wrote:
> Hi: I need to validate that records have been entered correctly in a
> table, by correctly I mean in ascending order. But with a small
> variation, the first record can have any value, so:
>
> Field1
> 100
> 2
> 3
> 4
> 5
> 6
>
> This is correct, because record 1 can have any value, but :
>
> Field1
> 88
> 2
> 3
> 7
> 5
> 6
>
> Is wrong, can I validate this using VF
Quite simply, you're heading about it wrong - the physical order of the
records should be immaterial. Instead, use an index or SQL-SELECT to
collect the records in the order that you want:

INDEX ON Field1 TAG Field1
SET ORDER TO Field1

will almost get you there, but that "Record 1" will give you trouble.
You may need a slightly more complex index expression:

INDEX ON (IIF(IsFirstRecord, -1, Field1)) TAG Field1
SET ORDER TO Field1

"IsFirstRecord" would be whatever it is that identifies it as a "First"
record. This is probably not a good approach, as the IIF(...) format
must be used in referring to this tag in order to let Rushmore kick in.

Can you describe your application in more detail? You're approaching a
relational database as though it were a spreadsheet - a common mistake,
and one that will cause you pain.

- Rush

RE: Validating data, tricky one... by Yan

Yan
Tue Sep 18 18:56:00 PDT 2007

You can use 2 variables for this scenario. One acts as a counter which counts
the number of inputs and the other would be the last inputted number. You'll
just have to validate the inputs if the inputted number is lesser than the
last inputted number when counter is greater than 2.


Ryan Paradela


"Texeira" wrote:

> Hi: I need to validate that records have been entered correctly in a
> table, by correctly I mean in ascending order. But with a small
> variation, the first record can have any value, so:
>
> Field1
> 100
> 2
> 3
> 4
> 5
> 6
>
> This is correct, because record 1 can have any value, but :
>
> Field1
> 88
> 2
> 3
> 7
> 5
> 6
>
> Is wrong, can I validate this using VFP?
>
>