Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for unique value
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00008459
Message ID:
00008482
Views:
37
>I have a database that has 2 tables in a 1-to-many relationship. It is indexed on location. When the user inputs a location, I want to make sure that location is not already in the parent table. Is this possible? I am new to VFP, so the more detailed the better. Thank you in advance.
>Bob Sides.

U have two choices. One check the field at data entry time. The second choice is to check at record save time. I personally prefer at save time from a system performance view point.

Using the valid method below for a LOC_ID field will allow you to check if an entry is already used when U attempt to leave the LOC_ID field. I use SQL over Seeking (which will also work). Make sure U have an index tag on LOC_ID for optimize.

* Location valid
SELECT LOC_ID ;
FROM LOCATION ;
Where LOC_ID = This.value ;
INTO array laTempHold

IF _Tally > 0
* Duplicate Found!
RETURN(.F.)
ELSE
RETURN(.T.)
ENDIF

Well, this is just something quick and very early in the morning. Hope this was Helpful (HtwH). Steve.
Steve Medvid
Systems Analyst

Environmental Resource Management
Previous
Reply
Map
View

Click here to load this message in the networking platform