copy field after modification

vios15vios15 Member Posts: 43
Dear Expert,

I am trying to capture the old field data to another field after modification.

eg. in the form, existing bin_location field I would like to change from "ABC" to "DEF", after changing, bin_location becomes "DEF" while Old_bin Location captured as "ABC".

How do I achieve it?

Thanks

Answers

  • vios15vios15 Member Posts: 43
    Hi,

    Thanks.

    It work after change it from the Form OnInputChange but I discovered that I need to move to next record in order for the change to take effect.

    Is it possible to update the change the moment my cursor leave the Bin_location.

    Thanks again.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    vios15 wrote:
    Hi,

    Thanks.

    It work after change it from the Form OnInputChange but I discovered that I need to move to next record in order for the change to take effect.

    Is it possible to update the change the moment my cursor leave the Bin_location.

    Thanks again.
    in which trigger you have written the code/
  • vios15vios15 Member Posts: 43
    Hi,

    OnInputChange at the Bin_location.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • vios15vios15 Member Posts: 43
    Hi,

    The result is the same, need to move to next record before being updated.

    I can see the Old_Bin Location being updated in the Form after changing the Bin_Location, if I hit "escape" key after leaving Bin_Location field, my record is not updated. If I press down arrow key to next record, my changes would take effect.

    Could it be other control in place?

    Thanks.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    i have performed this in Purchase order subform(Purchase line table) .

    i have created new field called newitem

    i have writen code in No. onvalidate trigger

    its working fine.

    after changing the item No., newitem field is automatically filled without moving to next record or pres down arrow.
  • DenSterDenSter Member Posts: 8,304
    vios15 wrote:
    OnInputChange at the Bin_location.
    You should never put this type of data manipulation code on forms. This should go into the OnValidate trigger of the field itself, in the table, not on the form.
  • vios15vios15 Member Posts: 43
    Hi,

    Thanks for the advice. Will take note.

    By the way, I know why in the FORM, not updated after leaving the field.

    From further search in mibuso, all I need to do, is to insert "Currform.Update(True)" into OnafterValidate.

    Problem solved.

    Thanks
  • DenSterDenSter Member Posts: 8,304
    Well solved... you made it work, which is always a good thing, but I would not call it a solution. In medical terms you have treated a symptom, but did not cure the patient :mrgreen: . It is still not a good idea to put code like that on the form.

    What if you need to create another form for the same table? Now you're going to have to look through all the code in this other form and decide what to copy, and managing versions will become more difficult. Code that handles validation should be written in the table triggers, not on the form.
  • vios15vios15 Member Posts: 43
    Dear DenSter,

    Thanks for the advise.

    I have reverted my decision from Form to Table validation after some investigation.

    Thanks
Sign In or Register to comment.