Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check duplicate in table buffered mode?
Message
From
19/10/1997 13:27:32
Juan Kh
Dataprop Technologies
Sungai Petani, Malaysia
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00055264
Message ID:
00055390
Views:
27
>>>How do I check for duplicate in table buffered mode? Do I have to do a 'COPY TO' a temp table before I check? It seems troublesome.
>>>
>>>This table buffering is really killing my time. Can someone please comment?
>>
>>Hi,
Hi John,

The main reason I seek from both ends is, if the first encounter is the current record I'm in (lnRecNo = RECNO()), I need to seek further down to see if there is really a copy of myself down there. I can do this in Access by using ObjectVariable.FindNext, but I don't know how to do that in VFP. The mechanism in my code is just a trick, there is no absolute way of solving this problem.


In order to make the routine generic, you need to at least pass two parameters to it, one is the Alias and the other is the IndexedField you like to search on. Since the new records appended in a buffered table is not visible in other DataSession (prior to the issuance of TABLEUPDATE()), you need to make sure you are in the same DataSession with the calling function.

Using the YourTable again in another area with different alias with not allow you to see the records you have just appended (where RECNO() < 0).

Regards,
juan

>>llRetVal = .T.
>>SELECT YourTable
>>SET ORDER TO YourIndexedField ASCENDING && Seek from TOP
>>lnRecNo = RECNO() && Remember where you are
>>cKey = YourValueToSeek
>>IF SEEK(cKey)
>> IF lnRecNo RECNO() && Found and is not where I was??
>> && It is duplicate, Do something.
>> llRetVal = .F.
>> ENDIF
>>ENDIF
>>
>>*-- If not found from the TOP, try to seek from the bottom
>>IF llRetVal
>> SELECT YourTable
>> SET ORDER TO YourIndexedField DESCENDING && Seek from BOTTOM
>> lnRecNo = RECNO()
>> cKey = YourValueToSeek
>> IF SEEK(cKey)
>> IF lnRecNo RECNO()
>> && It is duplicate, Do something.
>> llRetVal = .F.
>>
>> ENDIF
>> ENDIF
>>ENDIF
>>
>>
>>juan
>
>Juan.
>Your code looks pretty good but can you explain why you need to seek both from the top and from the bottom? In addition, can your routine be made more generic (use it as a function so you can call from other areas) by using the YourTable again in another area with different alias?
>
>Just wondering.
>John.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform