Temporary tables in forms to let user edit data?

A beginner’s question regarding the use of temporary tables: I would like to use a temporary table to collect user input that doesn’t need to go in the database permanently. Is there any way to display a temporary table in a form so that a user could change lines and insert new ones?

If you start the form using Form.Runmodal(form::XX, TempRec) it does not return the new values. You can try changing the FindRecord and NextRecord like on the Sales Statistics VAT subform. This also shows temporary data.

@marq - thanks for the reply.

quote:

You can try changing the FindRecord and NextRecord like on the Sales Statistics VAT subform. This also shows temporary data.

I had a look at the Sales Statistic and it’s subform and I’ve not yet understood how it’s possible to attach a temporary table to the table object on a form and how to read the content of it: The Sales Statistics table has a temporary global variable (TempVATAmountLine) and a subform (VAT Specification Subform) The subform has same same global TempVATAmountLine record and “VAT Amount Line” connected to the subform. I fail to see the current “Rec” to be declared as temporary. My very simple example looks like this: - Create a new blank form - Put a table object to it - Create a global variable for a temporay record to be connected to either the form or the table. Now my form looks like this Currently no table is connected to the form. I fail to connect the temporary variable to the table object or the form. (as well as to get any fields into it - as the field menu is also blank) If I select the properties of the table object, there’s no property accepting a source variable. If I look at the properties of the form, I can enter a source table by number or name of the table, but fail to declare it temporary. So I assume the form would display the table in the database rather than an empty temporary one. I plan to use the table in a request form for a report - so using sub tables would make the design more complicated than it’s worth it.

Ok, where to start… I’ve made a small test which works. I can mail you the fob if you want. These are the steps: 1. Create the desired table for the form 2. create a tabular form based on the table 3. put the following in the form: Global Var TempRec of the new table Create 4 Functions SetTempRec(Var NewTempRec) TempRec.DELETEALL; IF NewTempRec.FIND(’-’) THEN REPEAT TempRec.COPY(NewTempRec); TempRec.INSERT; UNTIL NewTempRec.NEXT = 0; GetTempRec(Var NewTempRec) NewTempRec.DELETEALL; IF TempRec.FIND(’-’) THEN REPEAT NewTempRec.COPY(TempRec); NewTempRec.INSERT; UNTIL TempRec.NEXT = 0; InsertRec TempRec := Rec; TempRec.INSERT; ModifyRec TempRec := Rec; TempRec.MODIFY; Change the following Triggers: Form - OnFindRecord(Which : Text[1024]) : Boolean TempRec.COPY(Rec); IF TempRec.FIND(Which) THEN BEGIN Rec := TempRec; EXIT(TRUE); END ELSE EXIT(FALSE); Form - OnNextRecord(Steps : Integer) : Integer TempRec.COPY(Rec); ResultSteps := TempRec.NEXT(Steps); IF ResultSteps <> 0 THEN Rec := TempRec; EXIT(ResultSteps); Form - OnInsertRecord(BelowxRec : Boolean) : Boolean InsertRec; EXIT(FALSE); Form - OnModifyRecord() : Boolean ModifyRec; EXIT(FALSE); ------------------- Then in your codeunit put something like TempTable.Code := ‘1’; TempTable.Description := ‘2’; TempTable.INSERT; TempTable.Code := ‘3’; TempTable.Description := ‘4’; TempTable.INSERT; TempForm.SetTempTemp(TempTable); TempForm.RUNMODAL; TempForm.GetTempTemp(TempTable);

Well, I am doing some more testing and to my suprise the Form.Runmodal(Form::XX, TempRec) also works… I always thought that is did not… So that makes it all a lot easier[8D] This means step 3 is not nessesery… And the codeunit is only TempTable.Code := ‘1’; TempTable.Description := ‘2’; TempTable.INSERT; TempTable.Code := ‘3’; TempTable.Description := ‘4’; TempTable.INSERT; Form.Runmodal(FormXX, TempTable); I Still like the fist option, nice and complicated[:D]

Thanks for the help! As I need the temporary table only within the request form, I didn’t need the SetTempRec/GetTempRec functions and added the delete-option. The rest worked fine, so now I can actually input a previously undefined number of multiple lines into a report. This is what I used from your instructions

quote:

These are the steps: 1. Create the desired table for the form 2. create a tabular form based on the table 3. put the following in the form: Global Var TempRec of the new table Create 3 Functions InsertRec TempRec := Rec; TempRec.INSERT; ModifyRec TempRec := Rec; TempRec.MODIFY; DeleteRec TempRec := Rec; TempRec.DELETE; Change the following Triggers: Form - OnFindRecord(Which : Text[1024]) : Boolean TempRec.COPY(Rec); IF TempRec.FIND(Which) THEN BEGIN Rec := TempRec; EXIT(TRUE); END ELSE EXIT(FALSE); Form - OnNextRecord(Steps : Integer) : Integer TempRec.COPY(Rec); ResultSteps := TempRec.NEXT(Steps); IF ResultSteps <> 0 THEN Rec := TempRec; EXIT(ResultSteps); Form - OnInsertRecord(BelowxRec : Boolean) : Boolean InsertRec; EXIT(FALSE); Form - OnModifyRecord() : Boolean ModifyRec; EXIT(FALSE); Form - OnDeleteRecord() : Boolean DeleteRec; EXIT(FALSE);

This works great. Wthin the report I have access to the temporary table and can “read” all the lines. There’s a strange design thing happening. On design, the request form looks like this: After saving it once, the fields have moved behind the table. I moved the table down a bit so you could see them. They still work - in the opposite order I put them in. I guess I need to learn more about forms. But as long as it works… PS: After posting this I tried the same with a real form instead of report request form. On normal forms, this problem does not exist. Maybe you’re just not supposed to use tables as report input???

Well, I guess if it works it is OK.[^] I’ve never done this on a report[Wow!]