Subform to show newest item prices on Item Card

A year ago I asked about having a subform in a form and only displaying the newest with a group of item prices. See: http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=1319 I made the code as described: In table 28 Item Price


**Function MyFind(Which : Text[250]) : Boolean** 
SETCURRENTKEY(
  "Item No.","Variant Code","Responsibility Center","Price Group Code",
  "Unit of Measure Code","Currency Code","Starting Date");
SETRANGE("Item No.", "Item No.");

IF FIND(Which) THEN BEGIN
  SETRANGE("Price Group Code","Price Group Code");
  SETRANGE("Currency Code","Currency Code");
  FIND('+');
  SETRANGE("Price Group Code");
  SETRANGE("Currency Code");
  EXIT(TRUE);
END ELSE
  EXIT(FALSE);

**Function MyNext(Steps : Integer) : Integer**
SETRANGE("Item No.", "Item No.");
SETCURRENTKEY(
  "Item No.","Variant Code","Responsibility Center","Price Group Code",
  "Unit of Measure Code","Currency Code","Starting Date");
MySteps := 0;
StepsMade := 0;
IF (Steps < 0) THEN BEGIN
  REPEAT
    SETRANGE("Price Group Code","Price Group Code");
    SETRANGE("Currency Code","Currency Code");
    FIND('-');
    SETRANGE("Price Group Code");
    SETRANGE("Currency Code");
    StepsMade := NEXT(-1);
    MySteps -= StepsMade;
  UNTIL (Steps = MySteps) OR (StepsMade = 0);
END ELSE BEGIN
  REPEAT
    SETRANGE("Price Group Code","Price Group Code");
    SETRANGE("Currency Code","Currency Code");
    FIND('+');
    SETRANGE("Price Group Code");
    SETRANGE("Currency Code");
    StepsMade := NEXT(1);
    MySteps += StepsMade;
  UNTIL (Steps = MySteps) OR (StepsMade = 0);
END;

IF StepsMade <> 0 THEN BEGIN
  SETRANGE("Price Group Code","Price Group Code");
  SETRANGE("Currency Code","Currency Code");
  FIND('+');
  SETRANGE("Price Group Code");
  SETRANGE("Currency Code");
END;

EXIT(MySteps);

In subform:


**OnFindRecord(Which : Text[1024]) : Boolean**
t.COPY(Rec);
IF NOT t.MyFind(Which) THEN
  EXIT(FALSE);

Rec := t;
EXIT(TRUE);

**OnNextRecord(Steps : Integer) : Integer**
t.COPY(Rec);
i := t.MyNext(Steps);
IF i <> 0 THEN
   Rec := t
ELSE
   CLEAR(Rec);

EXIT(i);

In version 2.01 it worked fine! Now upgraded to Attain 3.10 it will not work. It only displays one instances of every Item Price Group and if there aremore, then it gives an error. Does any have a clue?? [8)]

Actually I’m a little closer to a solution! I hope! Using the debugger and comparing the 2.01 to the 3.10 version, then the only different seams to be that the “Steps” in the “OnNextRecord” is initiated with 1 in version 2.01 and with 0 in version 3.10.

Don’t we developers just love these subtle “improvements” in the products we work with? [xx(]

Yes it’s so wonderfull!! I got other “nice” examples of more or less undocumented changes from 2.01 to 3.10. I.e. with the use of RUNMODAL on the OnVALIDATE code. That worked fine in 2.01 if you didn’t update the table indirectly, but now…

Another change that was introduced in 3.10 was that if You have a Tabular-Type Form with a FlowField in the “footer” of the form, You must do a CALCFIELDS in OnAfterGetRecord to have that field to reflect the value of the current records FlowField. This was implicit in previous versions.

We had similar fun after the upgrade from Office 97 to 2000. Navision’s SHELL function didn’t wait any longer for Word to finish when a document was opened, which is really great if you want to save the modified document back into Navision [:p]. This only happened when Word was already open at the time of the call to SHELL. After hours of searching and several (expensive) calls to Microsoft support it turned out that Word 2000, upon startup, checks if it is already running, and if so, yields control to the already running instance. The new process then dies immediately, giving Navision the illusion that it has finished. Fortunately, Word supports the /W and /N options, which cause it to keep the new process running independently. Thank you, Microsoft! [xx(]

Thanks Heinz, I had this problem also but just decided to ignore it and go another direction. Actually this should go into the “Tips & Tricks” forum. Would you please post it here to?

quote:


Originally posted by Admin
Actually this should go into the “Tips & Tricks” forum. Would you please post it here to?


Your wish is my command [:D]