Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I triger a field validation for a primary key
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00052119
Message ID:
00052450
Views:
37
>>>>Hi.,
>>>>
>>>>I am a new entrant to these forums and Visual Foxpro. I just want to know whether anybody can
>>>>help me with the following how to:
>>>>
>>>> I am creating a form based on a table with row buffering. I want the form to check the entry
>>>>in the primary key field as soon as the operator leaves the field while in add routine.
>>>>
>>>> Also I would like to know whether I can change the control source of the fields for add routines
>>>>to the memory fields and for all other purpose the base table fields as the control source.
>>>>
>>>>Thanks in advance. By the way I found a message in my name without myself ever knowing it ?
>>>>Is such a thing possible as this is my first ever message to this forum.
>>>>
>>>>alex
>>>Hi alex,
>>>
>>>I too, am very new to vfp, but I can answer your question. As long as your table has the index set as primary and you have your form set to row buffering, vfp will do this automatically. I have set up several forms like this. It also helps if you use the buttons from the wizard class that autmatically move through any table attached to a form. They allow adds, edits and deletes and ms wrote all the code for you already.
>>>
>>>Audie
>>
>>Hi Audie,
>>
>>Thanks. But I am looking for a way to get a warning just as the user leaves the field. I am not for the vfp
>>way. My question is - Is there a way to get the duplicated warning immediately after leaving the field in a
>>form.??. I am not using the surrogate keys.
>>
>>Thanks
>>
>>alex

If understand your question correctly, you want to check that the primary key value that the user enters is unique before the tableupdate()? If so, I have handled this using something similar to the following (I use surrogate keys for primary indexes, but occasionally I have other fields that I want to be unique too):

In the valid event of the bound textbox:
oldrec = recno()
locate for keyfield = this.value
if found()
return .F.
endif
go oldrec

Or you could do the same thing using a second alias of the same table, and you would not have to move the record pointer in the first table.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform