Has anyone got any code for cleaning duplicate records out of a table
(and willing to share!!)?

Save me re-inventing the wheel.

I have just finished a program to help with our stocktake next week. In
a procedural language like foxplus it would be really easy to write, but
as I am trying to learn VFP.....

I have to collect the following data:

Sheet_No
Order_No built-up from prefix, order, version, item
customer
Location
Quantity
Last_Operation

I have set validation code and tab orders and added three buttons to the
form:

report+maint no tab order
quit no tab order
save last in tab order

The thing is - if i leave my the validation code for the sheet_no text
box the buttons on the form are not accessible, so the reports and
maintenance button is not available until all of the textboxs are
validated. But if I comment it out then the buttons become available.
What am I doing wrong?

E.g.

thisform.prefix.valid code:

Tprefix=ALLTRIM(thisform.prefix.Value)

DO case

CASE Tprefix="M"
RETURN 1

CASE Tprefix="W"
RETURN 1

CASE Tprefix="S"
RETURN 1

OTHERWISE
RETURN 0

ENDCASE

Buttons are un-clickable at this point.

THX

Steve

Re: re-inventing the wheel / Tab order & Validating by Jeff

Jeff
Thu Mar 24 23:14:16 CST 2005

Hi Steve, here's some code for your duplicates issue:

SET DELETED ON
USE <Table>
RECALL ALL
USE DBF() ORDER <FieldThatContainsDupes> IN 0 AGAIN ALIAS Again
SET RELATION TO <FieldThatContainsDupes> INTO Again ADDITIVE
SET SKIP TO Again
SCAN
IF RECNO() # RECNO("Again")
DELETE
ENDIF
ENDSCAN
USE IN Again
SET SKIP TO
SET DELETED OFF
BROWSE NOWAIT FOR DELETED()

Or:

USE <Table> EXCLUSIVE
SELECT * FROM <Table> NOFILTER INTO CURSOR Uniques GROUP BY
<FieldThatContainsDupes>
ZAP IN <Table>
APPEND FROM DBF("Uniques")
USE IN Uniques

The second one might not work if you've got field names longer than 10
characters, but then again it might. Your mileage may vary.

Have fun!



"steve" <steve@xircon.freeserve.co.uk> wrote in message
news:%23bW1lCJMFHA.3080@TK2MSFTNGP10.phx.gbl...
> Has anyone got any code for cleaning duplicate records out of a table (and
> willing to share!!)?
>
> Save me re-inventing the wheel.
> I have just finished a program to help with our stocktake next week. In a
> procedural language like foxplus it would be really easy to write, but as
> I am trying to learn VFP.....
>
> I have to collect the following data:
>
> Sheet_No
> Order_No built-up from prefix, order, version, item
> customer
> Location
> Quantity
> Last_Operation
>
> I have set validation code and tab orders and added three buttons to the
> form:
>
> report+maint no tab order
> quit no tab order
> save last in tab order
>
> The thing is - if i leave my the validation code for the sheet_no text box
> the buttons on the form are not accessible, so the reports and maintenance
> button is not available until all of the textboxs are validated. But if I
> comment it out then the buttons become available. What am I doing wrong?
>
> E.g.
>
> thisform.prefix.valid code:
>
> Tprefix=ALLTRIM(thisform.prefix.Value)
>
> DO case
>
> CASE Tprefix="M"
> RETURN 1
>
> CASE Tprefix="W"
> RETURN 1
>
> CASE Tprefix="S"
> RETURN 1
>
> OTHERWISE
> RETURN 0
>
> ENDCASE
>
> Buttons are un-clickable at this point.
>
> THX
>
> Steve
>



Re: re-inventing the wheel / Tab order & Validating by Anders

Anders
Fri Mar 25 05:41:46 CST 2005

SELECT DISTINCT * FROM ´MyTable INTO TABLE dupfree.
This removes whole record dupes. If you specify columns instead of * , well
you' get a dupefree version of those columns
SELECT DISTINCT id, name, address FROM Customers ...

SELECT name, address, COUNT(*) FROM Table ;
GROUP BY 1,2 HAVING COUNT(*) > 1 ;
INTO CURSOR Xx READWRITE NOFILTER

SELECT * FROM Table T1 WHERE EXISTS ;
(SELECT * FROM Xx WHERE ;
T1.name=Xx.name AND T1.adress=Xx.address) ;
INTO CURSOR Dupes

SELECT * FROM Table WHERE UPPER(name) LIKE 'SM_TH%'
Everyone with name like SMITH, SMITHE, SMYTHE, ...

You can use the SOUNDEX() function to pick up soundalikes.
-Anders


"steve" <steve@xircon.freeserve.co.uk> wrote in message
news:#bW1lCJMFHA.3080@TK2MSFTNGP10.phx.gbl...
> Has anyone got any code for cleaning duplicate records out of a table
> (and willing to share!!)?
>
> Save me re-inventing the wheel.
>
> I have just finished a program to help with our stocktake next week. In
> a procedural language like foxplus it would be really easy to write, but
> as I am trying to learn VFP.....
>
> I have to collect the following data:
>
> Sheet_No
> Order_No built-up from prefix, order, version, item
> customer
> Location
> Quantity
> Last_Operation
>
> I have set validation code and tab orders and added three buttons to the
> form:
>
> report+maint no tab order
> quit no tab order
> save last in tab order
>
> The thing is - if i leave my the validation code for the sheet_no text
> box the buttons on the form are not accessible, so the reports and
> maintenance button is not available until all of the textboxs are
> validated. But if I comment it out then the buttons become available.
> What am I doing wrong?
>
> E.g.
>
> thisform.prefix.valid code:
>
> Tprefix=ALLTRIM(thisform.prefix.Value)
>
> DO case
>
> CASE Tprefix="M"
> RETURN 1
>
> CASE Tprefix="W"
> RETURN 1
>
> CASE Tprefix="S"
> RETURN 1
>
> OTHERWISE
> RETURN 0
>
> ENDCASE
>
> Buttons are un-clickable at this point.
>
> THX
>
> Steve
>