Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Valid & Error events
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00105397
Message ID:
00105426
Vues:
20
>Hello:
Rafael, if you wish to use the SEEK() technique of checking for a unique value for a candidate index, then USE a second copy of your table.
USE MyTable alias NewTable order tag CandID
sele NewTable
if seek(NewValue)
   MESSAGEBOX("The ID number already exists",48,"Sorry but..")
   return .f.
endif
If you are letting the user enter a primary ID, then you may wish to re-think your design. There have been many threads on Primary IDs, and the consensus is that developers should use a table of IDs that is incremented automatically when adding a new record.

And, of course, previous messages about trapping the Primary Key error and substituting your own behavior are also good advice.

HTH
Barbara

>I'm trying to figure out how to make the dammed form work properly, in the old days of FPW 2.6 you could have a valid routine like the following:
>
>IF SEEK(myvar)
>MESSAGEBOX("The ID number already exists",48,"Sorry but..")
>RETURN .F.
>ENDIF
>
>Now in VFP the lines are executed and return values per line so this is not possible, and besides, if your table's index is set as Primary, you get an error from the first line:
>
>SEEK(this.value) && Your valid event generates an Error, and there is no way as far as I've seen to keep the cursor in the same field, not even with an error routine that calls the objet's SetFocus event to force this.
>
>MESSAGEBOX("The ID number already exists",48,"Sorry but..")
>Myform.myfield.SetFocus
>
>How can I get this to work, the goal is to seek the user's input in the database, from the begining in order to force him to change it if already exists, but still have the index as Primary
>
>Thank you for your help.
Barbara Paltiel, Paltiel Inc.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform