Form Focus

mb6606mb6606 Member Posts: 30
edited 2009-07-23 in Navision Financials
Variables:
Purchase Line."no."
Text2 var code

Code:
On the ONVALIDATE section of field Purchase Line."no."
If Purchase Line."no.">5 then
currform.activate.text2

IT seems so simple but does not work. The cursor remains in the Purchase Line."no." field
I have no nextcontrols set. Anybody know why???

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    What are you trying to do?
    David Singleton
  • mb6606mb6606 Member Posts: 30
    I am trying to get the form focus to jump from one field to another field
    onvalidate based on an if then statment.
  • garakgarak Member Posts: 3,263
    if the "Item No." (Field "No.") on your line is greater then 5 :?: you want to jump to field Text2 after an validation of the field "No." :?: This will not work on SQL if you insert an 400. For the sql sorting, the 400 is smaller then the 5 (reason: It's not an integer field, No. is an Char field)

    Correct :?:
    Do you make it right, it works too!
  • David_SingletonDavid_Singleton Member Posts: 5,479
    well No. is code and 5 is integer, so no way this will even compile.
    David Singleton
  • garakgarak Member Posts: 3,263
    well No. is code and 5 is integer, so no way this will even compile.

    thats also ;-)
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,304
    no way this will even compile.
    Exactly why I don't think that form will even run with that code
  • mb6606mb6606 Member Posts: 30
    I simply want to change focus from field1 to field2 using the code currform.field2.activate in the onvalidate section of field1. The cursor should jump focus to field2 but it remains in field1.
  • garakgarak Member Posts: 3,263
    you can set the nextControl property or you write behind
    Field1 - OnAfterValidate()
    if COndition then //<-- if needed
      CurrForm.Field2.activate();
    

    Regards
    Do you make it right, it works too!
  • mb6606mb6606 Member Posts: 30
    garak wrote:
    you can set the nextControl property or you write behind
    Field1 - OnAfterValidate()
    if COndition then //<-- if needed
      CurrForm.Field2.activate();
    

    Regards
    Yes this is the code I am trying to use but for some reason if located on the OnAfterValidate()
    section the code has no effect. The Nextcontrol is undefined.
  • garakgarak Member Posts: 3,263
    doesn't work it (your if Condition is correct)) if you press ENTER or TAB but it works if you press the Courser Buttons?
    Do you make it right, it works too!
  • mb6606mb6606 Member Posts: 30
    garak wrote:
    doesn't work it (your if Condition is correct)) if you press ENTER or TAB but it works if you press the Courser Buttons?

    Does not work with any key. How does one move the focus to a specific field after validation (Enter Key) without using NEXTCONTROL??
  • DaveTDaveT Member Posts: 1,039
    Hi,
    You need to take into account the sequence that Nav fires triggers and excutates actions. What happens is that the field validates and then you issue the command to activate the second field (field2). Nav does this but then the action after the validate is to go the next field ( of the cative field) which is the NextControl of field2

    For example to get the sales order subform to return to the description field from the quantity field if the quantity is greater than 5 you would need to add in the OnValidate trigger :

    IF Quantity > 5 THEN
    CurrForm."No.".ACTIVATE;
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • mb6606mb6606 Member Posts: 30
    DaveT wrote:
    Hi,
    You need to take into account the sequence that Nav fires triggers and excutates actions. What happens is that the field validates and then you issue the command to activate the second field (field2). Nav does this but then the action after the validate is to go the next field ( of the cative field) which is the NextControl of field2

    For example to get the sales order subform to return to the description field from the quantity field if the quantity is greater than 5 you would need to add in the OnValidate trigger :

    IF Quantity > 5 THEN
    CurrForm."No.".ACTIVATE;

    Yes exactly what I am attempting to accomplish. Yet the cursor remians focused in the QTY field. IT does not jump to the description field. Even when I create simple test form I cannot get the focus to change unless I use nextcontrol.
  • BeliasBelias Member Posts: 2,998
    try to get rid of your "if" statement for now: in other words, do the "activate" every time.
    if it works, then your condition has something wrong, otherwise, try to change the trigger :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mb6606mb6606 Member Posts: 30
    Belias wrote:
    try to get rid of your "if" statement for now: in other words, do the "activate" every time.
    if it works, then your condition has something wrong, otherwise, try to change the trigger :wink:

    Even if I create a simple test form with NO,DESC,QTY and no controls and no code and then add code to the onvalidate tigger of NO field the code
    CURRFORM.QTY.ACTIVATE;
    The focus should jump to the QTY field yet remains in the no field.
  • BeliasBelias Member Posts: 2,998
    which nav version?
    it MUST work (as it works for me and everyone else i think)
    try to name your textboxes (i literally mean "name" property of the textboxes), and then use currform.nameoftextbox.activate
    this is to check if you're calling the wrong control.
    anyway, did you try to comment the "if" statement, leaving only the "activate" instruction?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mb6606mb6606 Member Posts: 30
    Belias wrote:
    which nav version?
    it MUST work (as it works for me and everyone else i think)
    try to name your textboxes (i literally mean "name" property of the textboxes), and then use currform.nameoftextbox.activate
    this is to check if you're calling the wrong control.
    anyway, did you try to comment the "if" statement, leaving only the "activate" instruction?

    I am using v3.6
    I had removed the "IF" statement in my previous code testing.
    Perhaps the ZUP file is causing this problem? The currform.activate does work on the onactivate tigger and the drilldown triggers. It will not work on the onvalidate or onaftervalidate triggers. If I try on the onformat section it crashes Navision.
    Could be Navision v3.6 problem as this is very simple code.
  • BeliasBelias Member Posts: 2,998
    no, not a bug of 3.60...it works on my 3.60 sql db...
    have you got some other code under the onvalidate of the table or the form?which code?
    did you check the properties?is the destination field focusable(this is really stupid but who knows)?is it on the same tab?(i don' remember if the activate works across different tabs)
    well, i think your problem is a nondefault property or some code under validates...i cannot try guess more than this! :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mb6606mb6606 Member Posts: 30
    Belias wrote:
    no, not a bug of 3.60...it works on my 3.60 sql db...
    have you got some other code under the onvalidate of the table or the form?which code?
    did you check the properties?is the destination field focusable(this is really stupid but who knows)?is it on the same tab?(i don' remember if the activate works across different tabs)
    well, i think your problem is a nondefault property or some code under validates...i cannot try guess more than this! :mrgreen:

    Yes I even created a new table and form with zero code. onvalidate - Currform.var1.activate now jumps the focus to the HELP button. I know Navision forms has bugs this must be another.
Sign In or Register to comment.