On Oct 5, 2008, at 6:57 AM, Sibylle Koczian wrote:

> If I put the code for checking field A and doing the necessary  
> calculations
> into onNew() or afterNew(), then it is executed before anything is  
> entered in
> the form. So field A has still its default value 0.

        Yes, since this fires after the new record is created in the local  
data set.

> If I put it into onSaveNew(), then something curious happens: when I  
> press
> the "Save" button I get a message box with the question "Do you wish  
> to save
> your changes?" and when I press "Yes", then I get this error message:
>
> Save Failed:
>
> columns artikel, ausg_datum, firma are not unique
> SQL: insert into "ausgaben"
> ("aufschlag", "firma", "orig_betrag", "ausland", "abrech_datum",  
> "ausg_datum",
> "artikel", "bemerk", "waehrung", "kauf_typ", "euro_betrag", "kurs")  
> values
> (3.322960944517748389342800287, 'IB Phoenix', 132.54, 1,
> NULL, '2008-10-05', 'Firebird CD', '', NULL, 'I',
> 189.8834825438713365338743021, 0.698007)
>
> This looks as if the method tries to insert the same record twice. I  
> did check
> in the database table: there was no other record with the same  
> values before
> I created the new one, but afterwards it is there, only without the
> calculated values. In the error message those values are there (the
> fields "euro_betrag" and "aufschlag").
>
> What happens here?

        In this case you are saving the new record, then modifying it before  
the process that clears the 'new' flags has had a chance to run, so it  
still thinks that it is new, and tries to insert the data again.

        The best place for this logic is the validateRecord() method, which  
will get called for every modified record before the changes are sent  
to the database.


-- Ed Leafe





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to