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
Bruce Strom
Prayer of St Ephrem:
O Lord and Master of My Life,
Take from me the spirit of sloth, meddling, ambition and vain talk.
But give me a spirit of prudence, humility, patience and love.
Yes Lord and King grant me to see my own sins and faults
and not judge my brother.
For You are Blessed Forever and Ever. Amen.