Hi,
I�m trying to display duplicate records after I have marked them in my table. For this example, let�s say that I�m checking for duplicate last names. While I can query and display all marked records, I would also like to display the original, unmarked records to which these dupes belong. Like this:
[unmarked()] Jim Johnson
[marked()] Bill Johnson
[marked()] Sam Johnson
[unmarked()] Tom Smith
[marked()] Bob Smith
[unmarked()] Bill Brown
[marked()] Tim Brown
[marked()] Jane Brown
etc.
Obviously, I want to omit any records that are unique (with unique last names, in this case) and only select those that have dupes along with those dupes as well. Once I find them, I would like to put a dupe-group number in a �DUPE_GRP� field (Numeric, 8, 0), so the result would look like this:
1 [unmarked()] Jim Johnson
1 [marked()] Bill Johnson
1 [marked()] Sam Johnson
2 [unmarked()] Tom Smith
2 [marked()] Bob Smith
3 [unmarked()] Bill Brown
3 [marked()] Tim Brown
3 [marked()] Jane Brown
etc.
I have tried the following script, but I think that hunting accident did more damage than the doctor indicated, because I think it looks as though it should work�
''XBasic
DIM counter as N
counter = 0
tbl = table.open(WorkFile)
query.description = "Find Marked Dupes"
query.order = "LAST + IIF(.NOT. MARKED(), 'A', 'B')"
query.filter = ""
query.options = "I"
tbl.query_create()
IF tbl.mode_get() > 0 THEN
ui_msg_box("Error:", "Stuck here, Boss! ")
END IF
tbl.fetch_first()
WHILE .not. tbl.fetch_eof()
IF marked() THEN
tbl.fetch_prev()
counter = counter + 1
commit_flag = .T.
tbl.change_begin()
ON ERROR GOTO Error_handler
tbl.dupe_grp = counter
tbl.change_end()
tbl.fetch_next()
WHILE marked()
commit_flag = .T.
tbl.change_begin()
ON ERROR GOTO Error_handler
tbl.dupe_grp = counter
tbl.change_end(commit_flag)
tbl.fetch_next()
END WHILE
tbl.fetch_next()
ELSE
tbl.fetch_next()
END IF
END WHILE
Error_handler:
commit_flag = .F.
END
Any insights would be appreciated - I'm trying to write a dupe-checker that will let me edit and report on duplicates in mailing lists.
Thanks (in advance) and regards,
Geoff Hollander
I�m trying to display duplicate records after I have marked them in my table. For this example, let�s say that I�m checking for duplicate last names. While I can query and display all marked records, I would also like to display the original, unmarked records to which these dupes belong. Like this:
[unmarked()] Jim Johnson
[marked()] Bill Johnson
[marked()] Sam Johnson
[unmarked()] Tom Smith
[marked()] Bob Smith
[unmarked()] Bill Brown
[marked()] Tim Brown
[marked()] Jane Brown
etc.
Obviously, I want to omit any records that are unique (with unique last names, in this case) and only select those that have dupes along with those dupes as well. Once I find them, I would like to put a dupe-group number in a �DUPE_GRP� field (Numeric, 8, 0), so the result would look like this:
1 [unmarked()] Jim Johnson
1 [marked()] Bill Johnson
1 [marked()] Sam Johnson
2 [unmarked()] Tom Smith
2 [marked()] Bob Smith
3 [unmarked()] Bill Brown
3 [marked()] Tim Brown
3 [marked()] Jane Brown
etc.
I have tried the following script, but I think that hunting accident did more damage than the doctor indicated, because I think it looks as though it should work�
''XBasic
DIM counter as N
counter = 0
tbl = table.open(WorkFile)
query.description = "Find Marked Dupes"
query.order = "LAST + IIF(.NOT. MARKED(), 'A', 'B')"
query.filter = ""
query.options = "I"
tbl.query_create()
IF tbl.mode_get() > 0 THEN
ui_msg_box("Error:", "Stuck here, Boss! ")
END IF
tbl.fetch_first()
WHILE .not. tbl.fetch_eof()
IF marked() THEN
tbl.fetch_prev()
counter = counter + 1
commit_flag = .T.
tbl.change_begin()
ON ERROR GOTO Error_handler
tbl.dupe_grp = counter
tbl.change_end()
tbl.fetch_next()
WHILE marked()
commit_flag = .T.
tbl.change_begin()
ON ERROR GOTO Error_handler
tbl.dupe_grp = counter
tbl.change_end(commit_flag)
tbl.fetch_next()
END WHILE
tbl.fetch_next()
ELSE
tbl.fetch_next()
END IF
END WHILE
Error_handler:
commit_flag = .F.
END
Any insights would be appreciated - I'm trying to write a dupe-checker that will let me edit and report on duplicates in mailing lists.
Thanks (in advance) and regards,
Geoff Hollander
Comment