Please help newbeeeeee...

Said
Member Posts: 20
Hi,
How do I loop through all records in a table from first to last?
I'm using this code but it only gives me the first record in the table:
Count :=0;
IF Customer.FIND('-') THEN
MESSAGE('Customer %1 is %2','Name',Customer.Name);
Count:=Count+1;
REPEAT
UNTIL Customer.NEXT <= 0;
Thank you
How do I loop through all records in a table from first to last?
I'm using this code but it only gives me the first record in the table:
Count :=0;
IF Customer.FIND('-') THEN
MESSAGE('Customer %1 is %2','Name',Customer.Name);
Count:=Count+1;
REPEAT
UNTIL Customer.NEXT <= 0;
Thank you
0
Comments
-
hi!
you should wirte the code you want to repeat in the repeat ... not before or after it
this should workCount := 0; IF Customer.FIND('-') THEN REPEAT MESSAGE('Customer %1 is %2','Name',Customer.Name); Count:=Count+1; UNTIL Customer.NEXT = 0;
0 -
Count := 0; IF Customer.FIND('-') THEN REPEAT MESSAGE('Customer %1 is %2','Name',Customer.Name); Count:=Count+1; UNTIL Customer.NEXT=0;
you don't need a count, cause you can get it so: Customer.COUNT
something different ... do you have any programing experience ? it doesn't seem so learning programing AND navision is very very hard. maybe you should take a course first ?0 -
The Count or any syntax should be between the repeat and the until otherwise you will only get the first record in the table.
If your purpose is to count all the records in the customer table than "Customer.Count" should be enough.
Also if you wish to modify or delete some records you should really think about using setfilter or setrange before the find syntax.
That way the processing goes faster.0 -
Thanks a lot for your help0
-
Don't put the count within the repeat. If you have 10,000 customers in your record set, you will count 10,000 times. Better to put in an extra line before the REPEAT, like this:
Count := 0; IF Customer.FIND('-') THEN BEGIN Count := Customer.COUNT; REPEAT MESSAGE('Customer %1 is %2','Name',Customer.Name); UNTIL Customer.NEXT=0; END;
0 -
...and for SQL use COUNTAPPROX...0
-
Use COUNTAPPROX if you don't want an exact number. If you want to know exactly how many records are in your filter, then do NOT use COUNTAPPROX, but use COUNT. The other one is meant to get a quick estimate of the number of records in your filter, and supposedly is easier on network bandwidth. But let's face it, if I want to know how many records, I have a good reason to want to know it, and I want an exact count. I never use COUNTAPPROX.0
-
May be...but as Microsoft says you have to use COUNTAPPROX if you use SQL...0
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