Hi All, I have a form with a sourcetable A and a Global B Datatype Record Subtype A. Then i add a button to the form. In The OnPush-Trigger of the Button i’ve programmed: B.RESET; B.SETRANGE(field1, field1); B.SETRANGE(field2, field2); IF B.FIND(’-’) THEN repeat message(’%1’, b.feld3); until b.next = 0; field1 and field2 are part of the primarykey of the table. The Loop shall repeat through the same records which are shown in the form. The Problem is, that the message shows only empty (initial) values, but there are still values in field3 for the records. When i open the table in the Objectdesigner and set the filter manually you can see the correct records with field3 filled. I hope i can show, what my problem is. Can anyone help me? Thanks in advance, Frank
Originally posted by FPulsfort
… B.RESET; B.SETRANGE(field1, field1); B.SETRANGE(field2, field2); IF B.FIND(’-’) THEN repeat message(’%1’, b.feld3); until b.next = 0; …
Is your field3 a flowfield? Then you have to calculate it. The filters in the code are OK? The filters in the posting make no sense.
B.RESET; B.SETRANGE(field1, field1); B.SETRANGE(field2, field2); IF B.FIND('-') THEN repeat **CalcFields(b.field3);** message('%1', b.feld3); until b.next = 0; bye André
Hi Andrè, thanks for your answer. field3 is not a flowfield. What i want to do is to repeat through all records shown in the form by an instance B of the sourcetable A of the form and look at the value of field3. I’ve tried the following: COMMIT; B.RESET; B.SETRANGE(field1, rec.field1); B.SETRANGE(field2, rec.field2); IF B.FIND(’-’) THEN repeat message(’%1’, B.feld3); until B.next = 0; but the result is the same. The message shows no values of field3. In the Debugger B.field1 and B.field2 are correct, but all other fields of B are empty (initial values). But there are values in the Table!!! What i want to do is, to look in the OnQueryClose-Trigger of the Form in field3 of all shown records, in order to prevent closing the Form, if several conditions are fullfilled. Are there other ways? Greeting, FRank
It sounds like the “setranges” aren’t working. Try changing the line; if B.find(’-’) then to; B.find(’-’); what happens? do you get the standard Navision error; “… ‘’ does not exist!” You could also try adding an extra filter after the setranges!!! [:)]
Just tested your code and it worked fine. However, noticed that your ‘message’ line of code has a typo? message(’%1’,b.feld3); should this not be; message(’%1’,b.field3); other than this, like I said, the code works fine! [:D]
Hi CMDunbar, Yes, it should be field3 in the message but thats only a typo here in this text, note in the code. Yes, thats what i expect from this little simple code…it should work…but, nevertheless it doesn’t. so my searh goes on… Any other ideas out there? Greetings, Frank
Maybe try to restart your PC and rewrite the code [:D] Why do you use COMMIT before code? If field1 and field2 are part of Primary Key, can’t you use .GET to get this record? Have you tried to use B.COPY(Rec), B.COPYFILTERS(Rec)? And finally - why don’t you use current record but through variable?
Hi Arthur, I use Commit, because the user can make changes in the shown records of the form. I can’t use Get, because there are more than one record. I don’t use the current record, because i do not want to show the cursor going from one record to the next and after the loop the system comes with the question, if i want to rename the record. I’m not quite sure, but i think that is, because the user can do changes but not insert a new record in this form. Is that right? Arthur, you give me the right solution. I’ve written the code once again and …it works fine. I have found the solution. I have made a big mistake. I havn’t seen the forest, because of too many trees. In my Setrange’s i used one wrong field, so wrong records were shown. I should think about a long holiday… Sorry and thanks to all, who helped me. Greeting, Frank
Hi Frank, Maybe an obvious question but your variable B is real table not set to temporary, right? Regards, Cristi Nicola
Hi Cristian, Yes, B is a real table. Greetings, Frank