>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only