Hello ,
This code is overwriting the last record when the custid
doesn't exist already. The update section works perfectly. So, when
an existing customer fills the field for saving to this db, and hasn't
done it yet, it should be in the MvElse section because
CCCcodes.d.custid is NULL , where it adds the
record by overwriting the last record in the db.
Should I MvGo to the end of the db and then add the record? I thought
MvAdd would do this automatically -- I've obviously missed something
here -- probably simple too :-) TIA.
<MvASSIGN NAME = "l.ok" VALUE = "{ CCC_Open_Store() }">
<MvFILTER NAME="CCCcodes" FILTER="{ CCCcodes.d.custid EQ customers.d.id AND NOT CCCcodes.eof }">
<MvIf EXPR="CCCcodes.d.custid">
<MvASSIGN NAME="CCCcodes.d.custid" VALUE="{customers.d.id}">
<MvASSIGN NAME="CCCcodes.d.ccodes" VALUE="{g.qvalue}">
<MvUpdate NAME = "CCCcodes">
<MvElse>
<MvASSIGN NAME="CCCcodes.d.custid" VALUE="{customers.d.id}">
<MvASSIGN NAME="CCCcodes.d.ccodes" VALUE="{g.qvalue}">
<MvADD NAME = "CCCcodes">
</MvIf>
<MvASSIGN NAME = "l.ok" VALUE = "{ CCC_Close_Store() }">
BTW: works the same with or without "NOT CCCcodes.eof" in the filter.
And there are only 2 fields in the db, custid and ccodes.
--
Best regards,
Scott
mailto:[email protected]
Comment