strange behavior of OnFindRec & OnNextRec

I’m trying to make form, which is sorted & showed depending on another table. I have table X: No.# Inventory No. 1000#A 2000#C 3000#B 4000#F … So, I have form with Inventory table in Rec, But in trigers OnFindRec & OnNextRec & OnAfterGetCurrRec I’m using table X. It looks like I’m walking on table X but showing Inventory. Every thing is OK then I have less records than can fit in window. But if you have more records, starts trouble. On Open Form NF calling OnNextRec triger RecCountInWindow x2 times !? Why ??? Using trigers I can’t catch then NF going thrue rec’s second time. If I using Next or Find func. on Rec in thesse trigers NF secretly switches to CurrRec on next refresh cycle, but if I using another table than rec NF don’t switch to CurrRec. After open form every thing looks OK, expect then you pressing PgUp or PgDw twice sometimes form refreshed incorectly. I think that algorythm of open form is most mysteriuos thing in NF :slight_smile: Maybe somebody used such tricks & have god solution ? There is log of open form: download

I don’t understand your problem. For the following reasons: 1) You use a shadow-table X to display inventories. Question: Why don’t you use Inventory directly? (Probably adding a new key) 2) Assuming that you are doing this because you need the form to be sorted according to a value which does not exist in the inventory table: Why do you need to put code in the OnNextRecord trigger rather than OnAfterGetRec? 3) You somehow need an algorythm to get records from your inventory table based on contents of the current record X. So there must be a one-to-one reference between these tables. Why can’t you use flowfields or a function which gets the appropriate record? Generaly you question reads: “I have a problem which I try to solve like this … but the solution I have in mind doesn’t work.”. Well, probably you are on the wrong way and your approach with two tables is wrong? What is the original problem and what made you come to this solution? Marcus Fabian phone: +41 79 4397872

OK, Markus I will start from end of your questions: My customer Once per month creating goods list and price list. They have about 3000 rec of goods. Customer can buy form indvidual list only (from 50 up to 300). All customers are divided to groups of assortiment. They want to sort each group indvidualy. So I have maded table X Line No.(int)#Inventory No.(code 20)#Assortiment group(code 10)#Starting Date(date)#valid (boolean) There goes answer to question No 1) What kind of key ? 2) If I will use OnAfterGetRecord Form will go thrue all 3000 insteed 300, If there are FlowFields, form will be slow. and will be difficult to change order of inventory. 3) Any flow flow can’t do that. Becouse IN KEYS YOU CAN USE ONLY ASCENDING ORDER. Yesterday I finnaly maded this. Marcus You are right, there only ONE-to-ONE reference available. The bisgest my mistake was, that I tried to make ONE-to-MANY reference. But one question left unanswered: Why then opening form NF runs thrue records twice ??? It is couse problems on one-to-many relation. I meen this in strange behavior !!! There is bug in Trigers calling OR Mysterious algorythm ? Edited by - db on 2001 Mar 08 11:48:32

I know the problem from own experience. It’s a price-list. In my case, we only wanted to show Items on the price-list the customer had purchased recently. For a price-list you would need two tables anyway: A header which contains the Customer-No, and “Valid after”-date and a line table which holds the PK of the header, Group, item, Price etc. The only thing you would possibly have to add is a lookup or function which gets the Item.Price depending on the Customer Currency and the “Valid-After”-Date of the price-list. So far so good. The question why Navision is running twice through the table is impossible to answer. However I encountered exactly the same behaviour in other DB-applications: Delphi-DB-Tables and also MS-Access. So at least Navision is in good company. Marcus Fabian phone: +41 79 4397872