Show number selected

amadman114amadman114 Member Posts: 36
Howdy,
I need to find a way to show the users how many rows that have selected in a Navision subform.

What I currently have is this:
CurrForm.SETSELECTIONFILTER(GrecStockTake);
IF GrecStockTake.FIND('-') THEN
GintNumberSelected := GrecStockTake.COUNT;
CurrForm.UPDATECONTROLS;

However, the textbox on the form only seems to update after the user clicks away from the current selection. I don't understand why this wont work. Any pointers/workarounds?

Comments

  • krikikriki Member, Moderator Posts: 9,112
    The reason is that the form is not continually updated.
    You might try to use the "TimerInterval"-property to do regular checks (once every half second for example), and when you see a change in quantity, update the form. But keep your COUNTs in variables to avoid too much searching the DB and updating the form.
    Update the form ONLY if the COUNT has changed!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • vaprogvaprog Member Posts: 1,141
    There are several 'issues' with the code you posted.
    • Where is that code located? Where is the control to display the count located? Are both on the subform? Otherwise, how is GintNumberSelected shared between the two or else you'll get a count on the header, not on the line. If the control to display the count is on the subform, use COUNT as SourceExpression and forget about all the rest. (edit: The striked-through comment was bogus as SETSELECTIONFILTER is needed).
    • FIND is unnecessary
    • CurrForm.UPDATECONTROLS updates the captions only (at least, that is what is specified). You will have to use CurrForm.UPDATE

    One interesting alternative way to handle updates based on subform changes is the following post:
    Send messages from subform to parent form
    Timers sometimes are annoying, especially while debugging.
Sign In or Register to comment.