Dialog window and subform refresh

DakkonDakkon Member Posts: 192
edited 2005-01-14 in Navision Attain
I have a form with a header section and a subform with lines on it. On this form is functionality for the user to hit a specific key to be prompted with a dialog so that they can scan a series of barcodes until they are done (at which point they just hit escape). My problem is that I have found no way to make my form or more importantly the subform refresh after each scan. Here is my code:

(Reader is a dialog window and AddItemByUPC() is a function that adds an item line based on the scanned UPC code)
Reader.OPEN('Waiting for UPC Barcode Scan...\#1###################');
WHILE (TRUE) DO
BEGIN
   UPC := '';
   Reader.INPUT(1,UPC);
   AddItemByUPC(UPC);
   COMMIT;
END;
Reader.CLOSE;

The issue here is that I need each item added to the subform lines to appear after it is scanned. Currently, nothing actually refreshes until the user hits escape, and then all of the new lines suddenly appear. I tried changing the code to something like the following too:
WHILE (TRUE) DO
BEGIN
   UPC := '';
   Reader.OPEN('Waiting for UPC Barcode Scan...\#1###################');
   Reader.INPUT(1,UPC);
   Reader.CLOSE;
   AddItemByUPC(UPC);
   COMMIT;
   CurrForm.UPDATE;
END;

but that didn't seem to work either. Does anyone have any ideas?
Thad Ryker
I traded my sanity for a railgun :mrgreen:

Comments

  • g_dreyerg_dreyer Member Posts: 123
    Have tried changing one of your lines to:

    CurrForm.UPDATE(false);

    Regards,
    gus
  • eromeineromein Member Posts: 589
    You will maybe need to user the OnTimer trigger on the main form. Search the forum with the word OnTimer.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • kinekine Member Posts: 12,562
    Insert this after the imput to give the chance to OS update application windows etc... and don't forget to call CurrForm.UPDATE.
    YIELD;
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DakkonDakkon Member Posts: 192
    I really thought the YIELD command would be the ticket but it didn't work. I've tried CurrForm.UPDATE() with FALSE and TRUE parameters. I've tried closing the dialog in the loop before calling update and yield and then reopening it at the start of the loop. In short I've tried just about everything you suggested and that I can think of. The OnTimer results in the same problem. So far nothing seems to actually refresh the subform until the code ends. I really appreciate all the ideas so far :o
    ..any others?:)
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • kinekine Member Posts: 12,562
    Do not use Imput but some form and code insert into OnValidate or OnAfterValidate.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DakkonDakkon Member Posts: 192
    If I run the form in modal mode like I'd need to, I don't think it would update but I'll try it as last resort. The other problem I'd have with the form is that my users are not very computer literate, and they insist on running windows maximized, which will in turn maximize the popup window (and regardless of how much I explain I'm sure I'd get repeated calls of "I can't see the sales screen anymore!"). Is there a way to do a popup modal form in Navision that won't maximize even if the other windows and the app are already maximized?
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • kinekine Member Posts: 12,562
    I think no.

    And another solution - include the textbox for entering the code directly on the form where you have the lines and set NextControl to same control. After entering you will have active the same textbox for next imput...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DakkonDakkon Member Posts: 192
    Good call, that should just fine. I'll just create a textbox and make it invisible. Then when they hit the hotkey to enter scan mode, I'll just make the box visible and set focus to it :P
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • DakkonDakkon Member Posts: 192
    If someone does manage to find a way to make a subform refresh during this scenario I'd still be interested in hearing about it :)
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
Sign In or Register to comment.