Set Form Focus from Password Form

doddwelldoddwell Member Posts: 65
Hello

I only want a user to be able to edit certain fields on the "Bank Account Card" if they enter a password. To do this, I have added a button to the "Bank Account Card" that opens a "Password Form". If the user enters the correct password, the "Password Form" closes and calls a function on the "Bank Account Card" form called "UnlockControls".

If I call the "UnlockControls" function directly from the "Bank Account Card", the controls are unlocked as expected. If I call the function from the "Password Form", the function is called sucessfully but the controls remain locked. It's as though the form needs to receive the focus before it will unlock the controls...if this is the case, I'm not sure how to set the focus onto "Bank Account Card" from "Password Form".

Any ideas or different approaches gratefully received. Thankyou.

Comments

  • MBergerMBerger Member Posts: 413
    Hmmm, wild guess here ( but it is how i would code it ), but do you have a function in the OnAfterGetRecord trigger of the Bank account card to lock the controle when a user goes to another record ? Because i think OnAfterGetRecord() is called when you return from yoorpassword form.

    What you could try is have your passwordform return just a boolean, and then call the function to unlock the controls from the bank account form based on that return value.
  • doddwelldoddwell Member Posts: 65
    Thanks MBerger.

    The OnAfterGetRecord trigger was being fired. I did something along the lines of you suggestion:

    1 - Created a Generic Password Form
    2 - Created a SINGLE INSTANCE Code Unit
    3 - Button on my Bank Account Form that passes Form ID to the Code Unit and then Opens the Password Form
    4 - Created a Setup table to store the Password

    Operation:
    1 -User clicks button on Bank Account Card that passes form ID and form name to Code Unit. Form then modally opens Password Form
    2 - User enters Password and, when they press Submit, entered password is compared to password stored in the table.
    3 - If Password is correct, Password form closes and OnAfterGetRecord of the Bank Account Form Fires. I then use this trigger to get the Password status from the Code Unit and make my controls editable/Not editable
    4 - Bank Account Form OnAfterGetCurrentRecord Then fires and and I call a function in the code unit that resets the Password Status
Sign In or Register to comment.