Scanning into NAV 5 SP1

DavidTDavidT Member Posts: 9
The Problem:

1. I have created a form with a table box.
2. The user scans the barcode and I insert the record into the table box.
3. Everything is perfect BUT once you scan more lines than you can physically see in the table box NAV does not automatically scroll to the last record so you can see what you've just scanned.

I have looked through the online postings, tips and tricks and I cannot find any way where I can force NAV to scroll to the last record scanned. I even sorted it in descending order hoping that NAV would show the first record as the last scanned entry but the table box does not refresh. Everytime I have to manually scroll to see the last record scanned.

I have changed properties on the form which only work if the form is re-opened but I need NAV to refresh the table box and show the last record scanned after each insertion of a line. Calling a CurrForm.UPDATE(FALSE) does not refresh the table box either.

Can anyone help me? ](*,)

David

Comments

  • AdministratorAdministrator Member, Moderator, Administrator Posts: 2,499
    [Topic moved from Navision Attain to Navision forum]
  • awarnawarn Member Posts: 261
    My guess without looking is that you would need to not just update the tablebox, but activate it. Normally you can update it but until the user clicks on it (activates it), the change isn't shown on the screen.

    I do not think though you can activate a tablebox - you might want to try and put the tablebox in a subform, and call a function in the subform to update it, and then activate it. The problem you would run into though is that then the cursor will be on the subform - not where you want the user to be scanning.
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    How r u inserting record in the Table...?? Where is the code written for that..?? :|
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    here r two objects ...
    1) one form with a table Box and
    2) The source table for the form

    Just check if it helps you....... O:)
    OBJECT Form 50008 table box test
    {
      OBJECT-PROPERTIES
      {
        Date=07/08/08;
        Time=[ 5:32:20 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=18590;
        Height=8470;
        SourceTable=Table50000;
      }
      CONTROLS
      {
        { 1102753000;TableBox;11000;880 ;2750 ;5500  }
        { 1102753001;TextBox;0    ;2530 ;1210 ;440  ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr=No }
        { 1102753002;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753001;
                                                     InColumnHeading=Yes }
        { 1102753005;CommandButton;2640;3630;2200;550;
                                                     CaptionML=ENU=Insert;
                                                     OnPush=BEGIN
                                                              t.INIT;
                                                              t.RESET;
                                                              IF t.FINDLAST THEN
                                                                t.No := t.No + 1
                                                              ELSE
                                                                t.No := 1;
    
                                                              t.INSERT();
                                                              IF FINDLAST THEN;   // put cursor on the last line
                                                            END;
                                                             }
        { 1102753006;CommandButton;2640;4950;2200;550;
                                                     CaptionML=ENU=Deleate All;
                                                     OnPush=BEGIN
                                                              t.INIT;
                                                              t.DELETEALL;
                                                            END;
                                                             }
      }
      CODE
      {
        VAR
          t@1102753000 : Record 50000;
    
        BEGIN
        END.
      }
    }
    

    OBJECT Table 50000 Table box test table
    {
      OBJECT-PROPERTIES
      {
        Date=07/08/08;
        Time=[ 5:32:58 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;No                  ;Integer        }
      }
      KEYS
      {
        {    ;No                                      ;Clustered=Yes }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • DavidTDavidT Member Posts: 9
    Hi Sandeep

    I imported your objects and yes it will work because you are calling a FINDLAST after inserting the record and you are working on one instance.

    This is my design:
    1. I have a Scan Header (main form) which shows a running total of the different items scanned.
    2. I have a Scan Lines (sub form) which shows the scanned lines. This is the form that doesn't scroll to the last record.
    3. The user scans the barcode into a textbox on the main form, a codeunit is called which processes the barcode and inserts the data into the Scan Line table. Therefore I am using a second instance to achieve this.
    4. Execution of the program returns to the textbox for the next scan. The subform does not scroll to the entry just scanned.

    I need to be able to force the SubForm to show the last record...any ideas?

    David
  • ara3nara3n Member Posts: 9,256
    I suggest to have the scan dialog in the subform instead of the form.

    I suggest also to just have a form which would show the lines.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DaveTDaveT Member Posts: 1,039
    Hi David,
    Another suggestion is to put the textbox for scanning in the subform
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • DavidTDavidT Member Posts: 9
    Hi Ara3N,

    I cannot place the lines on a new form because the customer wants to see the Header entries because this shows him specific item details which must be visible at all times.

    Hi Dave,

    I have placed the scan textbox on the subform but I have a runtime error when I press the Enter key while focus is on this textbox. Even with no text entered and all code removed from the form, NAV 5 gives the following error: "A(n) label cannot be activated." I don't even have any label on the subform.

    The subform will open but once you click on the textbox and hit enter the error always occurs.

    Have you experienced this?
  • DavidTDavidT Member Posts: 9
    Hi Dave,

    If you place a textbox on a Main form and set the NextControl to itself, then after any messages are displayed, the cursor will return to the textbox. If you place this textbox on a Sub form you will get the above-mentioned error.

    However, the SubForm tablebox still does not jump to the last record just scanned....so the original problem persists.
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi David,
    just try this and see if it helps..... O:)

    1) for scan line form --> Properties : SourceTablePlacement : Last
    2) In scan header form after calling to your codeunit
    CurrForm.UPDATE(FALSE);
    COMMIT;
    FORM.RUNMODAL("Id of your scanHeader Form",Rec);
    CurrForm.CLOSE;
    

    you may have to call your CodeUnit as
    if (CODEUNIT.RUN(Number [, Record]) then
    begin
    CurrForm.UPDATE(FALSE);
    COMMIT;
    FORM.RUNMODAL("Id of your scanHeader Form",Rec);
    CurrForm.CLOSE;
    end;
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi David,
    here is another (and cleaner) solution ... :P
    1) for your scan line form --> Form - OnAfterGetCurrRecord()
        IF FINDLAST THEN;
    
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • DavidTDavidT Member Posts: 9
    Thanks Sandeep,

    Both your ideas work but unfortunately they give new problems:

    Option 1: Open New Form ](*,)

    Each form closed is not really being closed. It is not freed from memory.

    The users will use my scanning functionality for Sales, Transfers and Stock Takes. On average they will scan about 20 lines or more. This means that there will be about 20 Forms or more listed under the Window menu item on the Tool Bar. As a result of this, when you close the form you are on, NAV freezes while it closes all the other forms as well.

    Option 2: FindLast on OnAfterGetCurrRecord ](*,)

    I call a FindFirst because I sort the entries in descending order. This will refresh the table box but you can't scroll properly because each time you scroll you trigger the OnAfterGetCurrRecord and it re-positions the cursor on the first record, therefore you never get to the end of the tablebox.

    Thanks for your help so far. I do appreacite it...

    David ](*,)
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi David,
    here is a bit updation in the "Option 2" approach ....... O:)

    1) In scan line form --> declare a global boolean : gotoLast
    2) In scan line form --> declare a Function : SetGoToLast
    3) In Function SetGoToLast()
         gotoLast := TRUE;
    
    4) In scan line form --> Form - OnAfterGetCurrRecord()
    IF gotoLast THEN
    BEGIN
       gotoLast := FALSE;
       IF FINDLAST THEN;
    END;
    
    5) In scan header form after calling to your codeunit
      CurrForm.LineSubForm.FORM.SetGoToLast;
    


    I hope it helps......... O:)
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • DavidTDavidT Member Posts: 9
    Thanks Sandeep...I have tested it and everything looks good to me.
    Just shows you how helpful it can be to have a fresh pair of eyes. \:D/

    Thanks very much for all your help....much appreciated !!! =D>
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    its my pleasure David O:) O:)
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
Sign In or Register to comment.