Counting no. of records selected

ptijsma
Member Posts: 17
Hello,
I want to count the no. of records selected in a Tablebox. (Selected, not marked)
If No. selected eq 1 i need to get info out of this record (thats easy), and when No. > 1 do nothing. (thats the tricky part cause i cant find a way to count the number of records selected)
Any help is much appreciated.
Screenschot:
https://mail.rainbowsolutions.nl/CHE6004679.GIF
Thanks
Peter
I want to count the no. of records selected in a Tablebox. (Selected, not marked)
If No. selected eq 1 i need to get info out of this record (thats easy), and when No. > 1 do nothing. (thats the tricky part cause i cant find a way to count the number of records selected)
Any help is much appreciated.
Screenschot:
https://mail.rainbowsolutions.nl/CHE6004679.GIF
Thanks
Peter
0
Comments
-
Change the properties of the textbox:
Editable: No
SourceExpression: COUNT
Even if you set any filters, this field will be updated automatically.
Is this the solution of your problem?
Regards
Michael0 -
The problem is, that the user still must be allowed to change the value in the textbox.
Also, the textbox may only be filled with the first record selected. So if more that one record selected, nothing may happen after the first selected.0 -
Check out the SETSELECTIONFILTER command.
Perhaps that might help in some way??This isn't a signature, I type this at the bottom of every message0 -
Nope. Tried that but the problem is that SETSELECTIONFILTER sets a mark on all selected records AND sets the filter to MARKEDONLY.
Because the event needs to be triggered at OnAfterGetCurrRecord, the subform, remains empty BEFORE anything can be selected (because the fitler is set to MARKEDONLY).
Best thing would be to:
1. SETSELECTIONFILTER
2. Count records within the filter
3. Programming logic to update the field
4. Reset FILTER to what it was before point 1.
I only don't know how to achieve this, every time i tried something like this, my subform remained ampty, before anything was selected.0 -
I think that you are almost there. You just need to do the work in a copy of the current Rec.
Create a local variable -- 'MyRec', type Record, subtype <same record as the form>.
Then in the trigger, do something like this:MyRec.COPY(Rec); MyRec.SETSELECTIONFILTER; IF MyRec.COUNT = 1 THEN BEGIN // do your stuff here... END;
Because the SETSELECTIONFILTER is applied to MyRec, the form's Rec is left undisturbed...0 -
You should (almost) never use SETSELECTIONFILTER on rec, always it on a local variable.
CurrForm.SETSELECTIONFILTER(MyRec); IF MyRec.COUNT = 1 THEN BEGIN // do your stuff here... END;
I.e. read this thread for details: http://mibuso.com/forum/viewtopic.php?t=3734&Regards
Peter0
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