How to track the key 'Ctrl+F' and make record non editable

venkateshvenkatesh Member Posts: 51
Dear friends,
In a contact card while moving between records i am able to control the contact card's stage from editable to non editable.but,In Editable stage,when i use Ctrl+F for searching by positioning the cursor in contact number field,the record is opened in editable stage.
but,according to our requirement it should be in non editable stage.

please give me a solution.

thanks

Comments

  • Soft_TodSoft_Tod Member Posts: 43
    Hello.

    If I understand you correctly, you have placed code in the OnAfterGetRecord() trigger of the form to enable/disable the form.

    If you use OnAfterGetCurrRecord() you will be trigged whenever and however the record is change.

    Regards
    It is impossible to make anything foolproof, because fools are so ingenious.
  • DenSterDenSter Member Posts: 8,307
    If your Contact Card opens in non-editable state, and it turns into editable when you put your cursor in the No. field, then some code is probably doing this. What you need to do in that case, is open the Contact Card, turn on the debugger, and click the No. field. Then follow the debugger to see what happens, and make the necessary adjustments. It could be as simple as Tod says, but you could also have to modify your code.
  • venkateshvenkatesh Member Posts: 51
    hello,
    This works fine when i move from one contact to another by pressing
    previous or next button.but,when the from is already in editable stage and i use Ctrl+F,in the No.field .It opens the contact in editable stage itself.

    but for me it should open the contact in non editable stage.

    thanks
  • DenSterDenSter Member Posts: 8,307
    Could you paste the code in here, and tell us where (in which trigger) you put the code? Have you tried Tod's suggestion?
  • venkateshvenkatesh Member Posts: 51
    hello,
    i have pasted below the copy of my code .i have tried it as per TOD'S suggestion.please go through it .



    OnAfterGetRecord:


    /// (22.02.2006 eTV-Gs) M11 ... Start
    IF (xRec."No."<>'') AND (xRec."No."<>"No.") AND (NOT GIsContactDelete)
    AND (GOptStatus=GOptStatus::Open) THEN BEGIN
    LErrorMsg:='';
    IF ValidateOnNewContact(xRec,LErrorMsg) THEN BEGIN

    GRecContact.RESET;
    GRecContact.SETRANGE("No.",xRec."No.");
    IF GRecContact.FIND('-') THEN BEGIN
    GET(xRec."No.");
    Rec:=xRec;
    EXIT;
    END;
    END;
    END;
    /// (22.02.2006 eTV-Gs) M11 ... End



    SETRANGE("No.");

    /// (24.01.2006 eTV-GS) M1 ... Start
    IF (NOT GIsUnBlocked) OR
    ((xRec."No."<>"No.") AND ("No."<>'') AND (xRec."No."<>'')) THEN BEGIN
    GOptStatus:=GOptStatus::Close;
    CurrForm.EDITABLE:=FALSE;
    CurrForm.UPDATECONTROLS;
    END ELSE IF (GIsUnBlocked) OR (GIsNewContact) THEN BEGIN
    GOptStatus:=GOptStatus::Open;
    CurrForm.EDITABLE:=TRUE;
    CurrForm.UPDATECONTROLS;
    GIsNewContact:=FALSE;
    END;
    IF GIsNewContact THEN BEGIN
    GOptStatus:=GOptStatus::Open;
    CurrForm.EDITABLE:=TRUE;
    CurrForm.UPDATECONTROLS;
    GIsNewContact:=FALSE;
    END;


    LContactJonResp.RESET;
    LContactJonResp.SETRANGE(LContactJonResp."Contact No.","No.");
    IF LContactJonResp.FIND('-') THEN BEGIN
    REPEAT
    LContactJonResp.CALCFIELDS(LContactJonResp."Job Responsibility Description");
    LJobDesignation:=LJobDesignation + FORMAT(LContactJonResp."Job Responsibility Description") +';';
    IF LJobDesignation=';' THEN LJobDesignation:='';
    UNTIL LContactJonResp.NEXT=0;
    END ELSE
    LJobDesignation:='';
    LJobDesignation:=DELCHR(LJobDesignation,'<>',';');
    /// (24.01.2006 eTV-GS) M1 ... End



    OnGetCurrRecord:


    /// (22.02.2006 eTV-Gs) M11 ... Start
    IF (xRec."No."<>'')
    AND (GPrvOptStatus=GPrvOptStatus::Open) THEN BEGIN
    LErrorMsg:='';
    IF ValidateOnNewContact(xRec,LErrorMsg) THEN BEGIN
    GRecContact.RESET;
    GRecContact.SETRANGE("No.",xRec."No.");
    IF GRecContact.FIND('-') THEN BEGIN
    GET(xRec."No.");
    Rec:=xRec;
    EXIT;
    END;
    END;
    END;
    /// (22.02.2006 eTV-Gs) M11 ... End


    OnFindRecord:


    RecordFound := FIND(Which);
    CurrForm.EDITABLE := RecordFound OR (GETFILTER("No.") = '');

    /// (22.02.2006 eTV-Gs) M11 ... Start
    GPrvOptStatus:=GOptStatus;
    GOptStatus:=GOptStatus::Close;
    CurrForm.EDITABLE:=FALSE;
    CurrForm.UPDATECONTROLS;
    /// (22.02.2006 eTV-Gs) M11 ... End

    EXIT(RecordFound);



    thanks.
  • Soft_TodSoft_Tod Member Posts: 43
    Sorry to say, but for me your code is a bit too complex to even try to analyse.

    My advice is to try what you want in a simpler way. F.ex. Skip the ValidateOnNewContact function, the receiving of Xrec and so on and focus on the Editable function only. You'll learn how it works and can add the functionality to your code.

    Regards
    It is impossible to make anything foolproof, because fools are so ingenious.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You need to try to debug the code after you've used CTRL+F. Check what piece of code is called and whether or not the findrecord trigger is called.

    If the findrecord trigger is not called you will need to change something to the code in the onaftergetcurrrecord trigger.
  • DenSterDenSter Member Posts: 8,307
    :shock: sheesh.... what are you trying to do? What is the purpose of all this code? Why are you manipulating data like that on a form? By making all these changes, you are making so that this form behaves completely differently from every other form, and you are taking the intuitiveness out of it.

    Wouldn't it be better to put the actual code in functions on the table, and call them from buttons?
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Yep, I agree. You only want to do this if you are absolutely sure there is no other way to achieve your goal.
Sign In or Register to comment.