Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for duplicate keys when entering data in form
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00252239
Message ID:
00252241
Views:
8
>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 could use a primary or a candidate index.
Previous
Reply
Map
View

Click here to load this message in the networking platform