Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for duplicate keys when entering data in form
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00252239
Message ID:
00252624
Vues:
9
>I am still new to VFP programming.
>It appears that to add a record to a database via a form, you APPEND BLANK and then have the user enter the new data.
>I did not see any controls that would generate an error message if you tried to enter a duplicate key as happens with BTrieve and other databases.
>Under FoxPro 2.6 you can either go to EOF and SCATTER MEMVAR and not add the record if it is already present.
>Under VPF though, if the blank record is already created it would appear that you would have to do the following in the Validate control for the key field:
>
>
>ThisForm.Validate
> m_suta_state = This.Value
> m_alreadythere = .f.
> m_recno = recno()
> GO TOP
> IF seek( m_suta_state )
> IF m_recno <> recno()
> m_alreadythere = .t.
> ENDIF
> ENDIF
> IF m_alreadythere
> m_thisrecord = recno()
> GOTO ( m_recno )
> DELETE
> GOTO ( m_thisrecord )
> StateUnemployment.Refresh
> ENDIF
>
>But this seems SO KLUDGY. Surely my understanding is incomplete.
>
>Thanks
>Bruce Strom

You should be assigning the PK in the database. Look at my KB article on Primary Keys on my web site.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform