Get the result from a variable and display in a table field

LeroyLeroy Member Posts: 199
Hello, I've two fields in a form and perform operations in a variable. It's possible get the result from that variable (show it in a form)and display in a table field?.
Thanks for help.

Comments

  • koubekkoubek Member Posts: 84
    If I`ve undestood well, You have probably two TextBoxes on the Form (representing underlaying table`s fields as a SourceExpr).

    You can change SourceExpr, to display just variables or You can perform the operation, save values from variables to record and automatically display instead of original values. Next way is to display only variables` values using output modification in trigger "OnFormat(VAR Text : Text[1024])" directly on the Controls (e.g. without changing of record`s values).

    So of course You can do it and You can choose which way is the best for You.
  • LeroyLeroy Member Posts: 199
    Thanks for reply. I don't understood very well, sorry. I explain it better.
    I've two fields from a table, field1 and field2 from table1, and I want, for example, multiply them, the I've created a decimal variable on form called "result"; on OnAfterGetRecord form I do the operation:
    result:=field1*field2;
    then result shows a quantity. This quantity, now, I want "to send" to a new field from a table, or, al least, to table1. I don't know if it is possible and if the same thing that you were trying to explain to me.
    Thanks for your help.
  • koubekkoubek Member Posts: 84
    Sorry, but this isn`t the best way how to do it... I must go through all changed records (e.g. somebody else changed values in field1 and/or field2 in many records in a different way - not using Your form - so multiplication was not processed) in the form, to be sure you have all of Your data correctly multiplied!!!

    Use validation of field1 and field2 (OnValidate trigger directly on the fields in the table) to multiply data and save them to another field in this table. Then You can simply display these values through normal field representation => using TextBox on the Form.
  • LeroyLeroy Member Posts: 199
    Thanks for reply. The problem is that one of these fields is a flowfield, then I think I can't do the operation in Onvalidate trigger from table. Any idea please?.
    Thanks in advance.
  • koubekkoubek Member Posts: 84
    FLOWFIELD shouldn`t be modified (but can receive OnValidate() event if set as Editable=Yes)!!! Problem is that Your data process is still wrong. Flowfield is calculated dynamicaly and only when you call CALCFIELD command for this field (or implicitely when the field is shown on a form). I think You don`t want to get result only at these moments!!! You have design it to calculate result when some other fields (from which are field1 and field2 calculated from) are changed.
  • LeroyLeroy Member Posts: 199
    Ok; I suppose is difficult, may be the best it's to change the work way and do something different.
    Thanks for your help.
  • manluemanlue Member Posts: 30
    Hi, thinking about the problem that may be a solution:

    If calculating Maintable.FIELD-S as product Maintable.FIELD-1 * Maintable.FIELD-2 this should be done in the OnValidate-Trigger of Maintable.FIELD-1 and Maintable.FIELD-2.

    Now your trouble is that Maintable.FIELD-2 is a FlowField which itself is calculated dynamically and this event is not to catch in a trigger.

    But FlowField-Calculation bases upon some Subtable.FIELD-X. Only if one of the referenced Subtable.FIELD-X changes the Maintable.FIELD-2 is updated dynamically.

    How about calculating Maintable.FIELD-S in OnValidate-Trigger of Subtable.FIELD-X (certainly first do "CALCFIELDS(Maintable.FIELD-2)" before calculate Maintable.FIELD-S).

    I'm not sure but logical that should work...
  • LeroyLeroy Member Posts: 199
    Thanks for reply; it should work. I'll try it.
    Thank you very much for your help.
Sign In or Register to comment.