Changing data on temporary tables

Hi, All I’ve been struggling with the following problem for a while: I’ve a form working on a temporary table, the temporary table is loaded in the trigger OnOpenForm with some selected record from the real table the temporary one is made after. In OnFindRecord there’s the usual coding: TempTable := Rec; IF NOT TempTable.FIND(Which) THEN EXIT(FALSE); Rec := TempTable; EXIT(TRUE); So is in OnNextRecord: TempTable := Rec; CurrentStep := TempTable.NEXT(Steps); IF CurrentStep <> 0 THEN Rec := TempTable; EXIT(CurrentStep); The table is loaded and shown correctly. There is only a check field which is editable on the form, its sourceexpression is a boolean field on the table. When the user checks or unchecks the field that is accordingly modified both in the temporary and in the real table via code in the OnValidate trigger. All seems to work fine, but as soon as the user moves to an other line on the form a message appears saying: "An other user has modified the record for this (TableCaption) after you retrieved it from the database. Enter your changes again in the updated window, or start the interrupted activity again. Identification fields and values … bla, bla, bla … " When the user presses OK all goes on as if nothing happened. [:(!] Any clue? [?] Thanks Anna

Have a look at CurrForm.Update

Perhaps change the place for the code writing in the real table, place in the trigger ONQuerryCloseForm.

quote:


Originally posted by PeterD
Have a look at CurrForm.Update


I did. It looks very nice![:o)] Anna

quote:


Originally posted by FGabriels
Perhaps change the place for the code writing in the real table, place in the trigger ONQuerryCloseForm.


I tried something like that - I quoted the whole part of code writing in the real table, which I can update later in a number of different ways. Then I tested the the form again and at first it seemed to work … I went happily on for a while checking and unchecking records until … BOINK … the message started to pop up again, [B)] first every now and then, then every three-four checks, then every time. [:(!] Atfer closing and opening the form it started seemingly working again. Should I instruct the user to close and restart the form every “n” checks? [}:)] Anna

Anna you could try something like this i have. OnOpenForm If Find(’-’) THEN REPEAT TempRec := REC; TempRec.INSERT; UNTIL Next = 0; Then OnAfterValidate of the the field you want to change you could have TempRec.GET(Key); TempRec.Field := Field; TempRec.Modify; Then OnCloseForm you do the same as The OnOpenForm trigger but for the real table and modify instead of Insert.

quote:


Originally posted by stepheng
Anna you could try something like this i have. OnOpenForm If Find(’-’) THEN REPEAT TempRec := REC; TempRec.INSERT; UNTIL Next = 0;


That’s substantially what I also have.

quote:


Then OnAfterValidate of the the field you want to change you could have TempRec.GET(Key); TempRec.Field := Field; TempRec.Modify;


That I had in the OnValidate trigger. Following your suggestion I tried to move it in the OnAfterValidate. Again the the form seemed to work better, but, after a while, the message popped up again. It seems to be somehow related to the number of performed updates. On the form I have a menu button with two items - “Check all” and “Uncheck all” which trigger a function that goes through all the records in the form and sets the check field accordingly. If I choose one of the abovesaid menu item, all the lines on the form are updated. After that, if I manually change a line and move, there comes the message. If I close and reopen the form, all seem to work well again. It is as if there were something that needs to be reset, but I can’t figure out what it is. Anna

The only way you can raelly get help, is by either a/ Showing the code, or letting us know what you are trying to do. There are always many different solutions to one problem, and it is all to common to get down one road so far that you don’t want to turn back. Sometimes though its the only way. My first guess (and working blind, since I have no idea what you are trying to achive), is that the sequence of triggers does not match the key strokes (or mouse clicks), and somewhere you are either inserting or modifying temporary records somewhere.

quote:


Originally posted by David Singleton
The only way you can raelly get help, is by either a/ Showing the code, or letting us know what you are trying to do.


I’d thought so. The problem with showing you the code is that the table involved is part of the Italian localisation, so most of you wouldn’t be able to compile and run the form, unless I sent along the table properly renumbered, so that you can work on it, maybe with some records to test it on. About what I’m trying to do - I’m trying (or to better say, I was trying) to have the user choose some records from a set of selected records and run a batch procedure on them. The procedure will fill a General Journal, post it and go back to the original table to make some updates. You might ask why I’m not using the real table to make the user choose and I can assure you I thought I had some very good reason when I started, but be damned if I remember! [:D]

quote:


There are always many different solutions to one problem, and it is all to common to get down one road so far that you don’t want to turn back. Sometimes though its the only way.


Indeed. Actually I already thought of a better (and certainly working) solution to achieve the goal, but I’m still banging my head on the problem I was describing out of sheer stubborness. I really can’t rest with a stupid form mocking at me! [}:)]

quote:


My first guess (and working blind, since I have no idea what you are trying to achive), is that the sequence of triggers does not match the key strokes (or mouse clicks), and somewhere you are either inserting or modifying temporary records somewhere.


Let’s see: the form is structured like form 344, with a card section, with some request filter fields and a Find button and an initially empty tablebox. OnOpenForm trigger: Retrives previously set filters, if there is any, and launchs the FindRecord function, or initialize form and tenporary table; Find button, OnPush trigger: FindRecord(); FindRecord procedure: WITH RigheEffTmp DO BEGIN Finestra.OPEN(Text1000000002,“Line No.”); RESET; DELETEALL; IF RigheEffetti.READPERMISSION THEN BEGIN RigheEffetti.RESET; RigheEffetti.SETRANGE(SICO_Scelta,TRUE); RigheEffetti.SETRANGE(SICO_NrDocumento, ‘’ ); //* non registrati RigheEffetti.SETRANGE(SICO_Tipo, FiltroTipo); //* simula SBF !! and some other filter settings which I’ll spare you Finestra.UPDATE(1, DocNrDiRecord); IF DocNrDiRecord > 0 THEN BEGIN RigheEffetti.FIND(’-’); REPEAT RigheEffTmp.INIT; RigheEffTmp:=RigheEffetti; RigheEffTmp.INSERT; UNTIL RigheEffetti.NEXT = 0; END; END; EsisteDoc := FIND(’-’); Rec := RigheEffTmp; IF NOT EsisteDoc THEN … (some complaint) CurrForm.UPDATE(FALSE); Finestra.CLOSE; OnFindRecord trigger: RigheEffTmp := Rec; IF NOT RigheEffTmp.FIND(Which) THEN EXIT(FALSE); RigheEffTmp.CALCFIELDS(“Customer Name”); Rec := RigheEffTmp; EXIT(TRUE); OnNextRecord trigger: RigheEffTmp := Rec; StepCorrente := RigheEffTmp.NEXT(Steps); RigheEffTmp.CALCFIELDS(“Customer Name”); IF StepCorrente <> 0 THEN Rec := RigheEffTmp; EXIT(StepCorrente); CheckBox in the TableBox, OnAfterValidate trigger (formerly it was OnValidate): RigheEffTmp.GET(Rec.“Customer Bill No.”,Rec.“Line No.”); RigheEffTmp.SICO_DaContabilizzare := NOT RigheEffTmp.SICO_DaContabilizzare; RigheEffTmp.CALCFIELDS(“Customer Name”); RigheEffTmp.MODIFY; { The following code has been removed RigheEffetti.GET(Rec.“Customer Bill No.”,Rec.“Line No.”); RigheEffetti.SICO_DaContabilizzare := NOT RigheEffetti.SICO_DaContabilizzare; RigheEffetti.CALCFIELDS(“Customer Name”); RigheEffetti.MODIFY; } Rec := RigheEffTmp; SetAll procedure (launched by the menu item “Check All” OnPush trigger): RigheEffetti.GET(RigheEffTmp.“Customer Bill No.”, RigheEffTmp.“Line No.” ); RigheEffetti.SICO_DaContabilizzare:= FALSE; RigheEffetti.MODIFY; RigheEffTmp.SICO_DaContabilizzare := FALSE; RigheEffTmp.MODIFY; UNTIL RigheEffTmp.NEXT = 0; Mhmm … here the real table is still updated along with the temporary one … That’s something I might try to change. Thank you for bearing with my ranting, guys [:D] Anna

Anna If you don’t want to update the real table at the time why don’t you try OnModifyRecord Trigger EXIT(False); On the form i created i didn’t want the real table updated, only the temp table for the pupose of passing parameters. So if you want update the real table you could do it when you close the form.

quote:


Originally posted by stepheng
Anna If you don’t want to update the real table at the time why don’t you try OnModifyRecord Trigger EXIT(False);


It works. Thank you, stephen. [:)] Anna