problem to exit a loop

flyingjuju
Member Posts: 35
Hello,
I search the last active seller for a specific customer.
I wish to exclude from the seller's result that the code "33", "13", "0", "1", starting with "I".
How should I do to move to the next record if the code is part of the vendor codes out?
Here is my code :
EnteteFacture.RESET;
EnteteFacture.SETCURRENTKEY("N° donneur d'ordre");
EnteteFacture.ASCENDING(FALSE);
EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect");
IF EnteteFacture.FIND('-') THEN REPEAT
Vendeur.GET(EnteteFacture."Code vendeur");
IF Vendeur.Actif = TRUE THEN BEGIN
IF "Code vendeur" = 33 OR "Code vendeur" = 13 OR "Code vendeur" = 0 OR "Code vendeur" = 1 "Code vendeur" = I* THEN BEGIN
//I do not know what to put in this place to jump to the next record
END;
"Code vendeur" := EnteteFacture."Code vendeur";
EXIT;
END;
UNTIL EnteteFacture.NEXT = 0;
Thank you for the help you can give me
I search the last active seller for a specific customer.
I wish to exclude from the seller's result that the code "33", "13", "0", "1", starting with "I".
How should I do to move to the next record if the code is part of the vendor codes out?
Here is my code :
EnteteFacture.RESET;
EnteteFacture.SETCURRENTKEY("N° donneur d'ordre");
EnteteFacture.ASCENDING(FALSE);
EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect");
IF EnteteFacture.FIND('-') THEN REPEAT
Vendeur.GET(EnteteFacture."Code vendeur");
IF Vendeur.Actif = TRUE THEN BEGIN
IF "Code vendeur" = 33 OR "Code vendeur" = 13 OR "Code vendeur" = 0 OR "Code vendeur" = 1 "Code vendeur" = I* THEN BEGIN
//I do not know what to put in this place to jump to the next record
END;
"Code vendeur" := EnteteFacture."Code vendeur";
EXIT;
END;
UNTIL EnteteFacture.NEXT = 0;
Thank you for the help you can give me
0
Answers
-
Why not exclude those records in first place?
EnteteFacture.RESET; EnteteFacture.SETCURRENTKEY("N° donneur d'ordre"); EnteteFacture.ASCENDING(FALSE); EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect"); EnteteFacture.SETFILTER("Code vendeur",'<>%1&<>%2&<>%3&<>%4&<>%5*','33','13','0','1','I'); IF EnteteFacture.FIND('-') THEN REPEAT Vendeur.GET(EnteteFacture."Code vendeur"); IF Vendeur.Actif THEN BEGIN ...
"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
Thank you. I had not thought of this solution0
-
after multiple tries, it does not work.
In fact, I would go to the next record if I come across a seller that has a code equal to 33, 13, 0, 1 or I *.
How do I do that?0 -
Hi
In my opinion, the code should be something as below:
EnteteFacture.RESET;
EnteteFacture.SETCURRENTKEY("N° donneur d'ordre");
EnteteFacture.ASCENDING(FALSE);
EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect");
IF EnteteFacture.FIND('-') THEN REPEAT
IF NOT (("Code vendeur" IN = 'I')) THEN BEGIN
Vendeur.GET(EnteteFacture."Code vendeur");
......
END;
UNTIL EnteteFacture.NEXT = 0;0 -
Thank you for this solution but it does not work.
I always record with these codes sellers.
Nevertheless, I think this is the right path.
Should maybe I put an else because if I get one of these codes sellers, I have to go to the next invoice.
How can I do that?
thank you0 -
Have still not found a solution to my problem, I'll explain again what I do.
We do loyalty campaigns.
Through my code, I get information about our prospects (name, address, code vendor area code, etc ...)
In these loyalty campaigns, I must search for each prospect the last sale of an active seller and get the code seller.
If unfortunately, the last active seller for a code 33, 13, 0, 1 or I *, I have to go to the next active seller.
If unfortunately, I have no active seller, I owe nothing to the code seller.
This is the part that is written in red I have a problem.
Someone would have a solution to offer me aside from what has already been0 -
It's not possible in an easy way to step to the next record in a loop that is based on the same recordset. What if the next record also doesn't match your conditions?
Both mentioned solutions should work in certain situations. If they don't you probably miss something. Why don't they work? How do your table relations and fields look like?"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
The computer thinks in yes/no, it does not understand "maybe this"/"maybe that". As a developer, it is YOUR job to translate the problem into yes/no, so you can program it to do what it needs to do.
To me this looks like you still have some translating to do. You have to go deeper into the detail in what steps are taken. Do you have a senior that you can ask for help? This is typically something that you would do working with someone standing at a white board or with pen and paper.
You will have to be more specific than "it doesn't work", that does not say anything about what is really wrong.0 -
Firstly, I do not have senior who can help me. That is why I am using this forum.
In addition, it is not that not everything works but my test I can still have codes Sellers 33 and I *
I realized also that my test IF NOT (("Salesperson Code" IN ) OR ("Salesperson Code" [1] = 'I') ) THEN BEGIN is useless because with or without I get the same result with no filter.
There is the STEFILTER happens to limit my results
If I take the example of the vendor code 33, I get 765 prospects without filter and with SetFilter only 7 but it is still too 70 -
I still don't understand what you want. to jump to the next record, you use NEXT, which is at the end of a REPEAT UNTIL loop. Anything you need to do during the loop you can program, but you have to be able to determine each step in the process.
You also need to be able to look at the same problem from a different angle. Instead of thinking "jump to the next record if something is TRUE", think about "only do something if the same thing is FALSE" and let the loop do its work.0 -
Hi,
Late reply but.....
Change your code toIF EnteteFacture.FIND('-') THEN REPEAT Vendeur.GET(EnteteFacture."Code vendeur"); IF Vendeur.Actif = TRUE THEN BEGIN IF (EnteteFacture."Code vendeur" = '33') OR (EnteteFacture."Code vendeur" = 13') OR (EnteteFacture."Code vendeur" = '0') OR (EnteteFacture."Code vendeur"[1] = 'I') THEN BEGIN
Hope you still have the problem0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions