Insert new line on Form

kinekine Member Posts: 12,562
Hello,

I have some small code crisis... ;-)

I need help with this problem:

I have form with table box connected to some table (record). Now, I need simulate F3 key (form is for some barcode reader which have no F3 button easy accesible). WHat is objective? After clicking on some button, new line is inserted on the end of the table box but this line is not inserted into table (is marked with *). I can't find any function, which insert new line in the table box through C/AL. I need to call OnNewRecord trigger on form etc...

Or simulate Mouse Click on new line in some field...

Thanks for any help.
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.

Comments

  • SavatageSavatage Member Posts: 7,142
    setting the NEXTCONTROL to itself should bring it to the next line also
    if whatever you are scanning is the same length you can set your MAXLENGTH of the field to whatever it is. Once the MAXLENGTH is reached it will pop the next line.

    I hope that made sence? :roll:
  • kinekine Member Posts: 12,562
    Yes, but within C/AL code I am not able to use these possibilities... :cry:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • MHollenderMHollender Member Posts: 5
    Simply insert a record variable:


    LineNo: integer
    SalesLine : rec 37

    CLEAR(SalesLine);
    SalesLine.SETRANGE("Document Type","Document Type");
    SalesLine.SETRANGE("Document No.","No.");
    if SalesLine.FIND('+') THEN BEGIN
    LineNo:= SalesLine."Line No."+10000;
    END ELSE BEGIN
    LineNo:=10000;
    END;

    CLEAR(SalesLine);
    SalesLine.VALIDATE("Document No.","No.");
    SalesLine.VALIDATE("Document Type","Document Type");
    SalesLine.VALIDATE("Line No.","LineNo");
    SalesLine.INSERT(TRUE);
    Miklós Hollender
    Navision Developer/Consultant
    Delta Elektronik Ltd.
    Budapest
    Hungary
    miklos.hollender@delta.hu
  • kinekine Member Posts: 12,562
    Sorry, but I wrote, that I want to not insert the line into table. I want to insert new line on form without inserting into table. The line must be with * marked (in left fixed column). New line before OnInsert is called... only input focus on new line in table box... :!:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • RobertMoRobertMo Member Posts: 484
    what if you make table-box non-editable and define a rec var for the same table and a tab control at top that shows all fields for editing.
    you could also add several buttons as:
    NEW: Calls MyRec.INIT
    SAVE: save new/changed rec. and refreshes table-box.
    DELETE: deletes current rec.
    When selecting a rec in table box you display values of current rec also in tab control.

    this tab control could be also on separate (new) window (that has no table behind) that opens only when pressing NEW button or MODIFY button...

    I know it's not Navision standard, but...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • fbfb Member Posts: 246
    Or... you could try a variant of the WshShell SendKeys trick...

    http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=12350
  • RobertMoRobertMo Member Posts: 484
    I was curious about Windows Scripting Host and it actually does the job pretty well (in WinXP).
    Just for other's that might find this thread:
    On a tabular form I declared global automation for 'Windows Script Host Object Model'.WshShell.
    Then used it on button:
    OnPush()
    wshShell.SendKeys('{F3}');
    
    and it inserted a new line with * in front. (Of course calling CREATE(wshShell) should happen before calling SendKeys)
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • kinekine Member Posts: 12,562
    Eureka, this is the solution...

    thanks RoberMo :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • RobertMoRobertMo Member Posts: 484
    Well, thanks go to fb also...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • fbfb Member Posts: 246
    ...who got the idea from Henrik Helgesen's post at http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=12350

    These online community things are great!
    8)
  • RobertMoRobertMo Member Posts: 484
    By the way, according to help for SendKeys, if you want to send something with CTRL (like CTRL+A to select all), it should look like:
    SendKeys('^A');
    or
    SendKeys('{^A}');
    
    But it doesn't work from Navision code. I suspect codepage conversion happens for "^" ?
    Anybody any idea?
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • fbfb Member Posts: 246
    Does it work if the letter is lowercase?

    http://support.microsoft.com/default.as ... -us;210197

    Do you need to sleep before/after the SendKeys (especially if the SendKeys is triggered with a keyboard shortcut)?

    http://support.microsoft.com/default.as ... -us;138624
  • RobertMoRobertMo Member Posts: 484
    :D Lowercase works! So:
    SendKeys('^a')
    
    :oops: It's logical. 'A' means SHIFT+a, so I was sending CTRL+SHIFT+a. The window menu selection misleads suggesting uppercase (Select All Ctrl+A)

    No sleep needed.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sign In or Register to comment.