Maximum entries in a table
hmigneron
Member Posts: 5
Hello all,
I have a table that I use in a subform. I want this table to store a maximum of say, 5 records. If the user tries to enter more than the 5 records, he should get a message saying that it's impossible to add more.
By adding some code in the OnNewRecord trigger of the subform, I get a message at the appropriate time:
Now, my problem is that when I use ERROR, the whole subform closes. When I use MESSAGE instead of error, the message is displayed fine, but the new record line is still selected afterwards, and the user can just continue entering data.
My question is: how can I display a message, and then select the fifth record whenever the user tries to insert more than 5 records.
Thanks
I have a table that I use in a subform. I want this table to store a maximum of say, 5 records. If the user tries to enter more than the 5 records, he should get a message saying that it's impossible to add more.
By adding some code in the OnNewRecord trigger of the subform, I get a message at the appropriate time:
IF COUNT >= 5 THEN BEGIN ERROR(Errormsg); END;
Now, my problem is that when I use ERROR, the whole subform closes. When I use MESSAGE instead of error, the message is displayed fine, but the new record line is still selected afterwards, and the user can just continue entering data.
My question is: how can I display a message, and then select the fifth record whenever the user tries to insert more than 5 records.
Thanks
0
Comments
-
I have had the same wish.
In the trigger OnNewRecord I have out a message.
In the OnInsertRecord I have put the same message, followed by EXIT(FALSE).
So if the user tries to add a record, he gets the message.
If the user still proceeds, then he gets the message and the record will not be inserted. The form will not be closed, and the previous line will be selected.
Maybe this helps you.Keep It Simple and Stupid (KISS), but never oversimplify.0 -
Does the trick for me!
Thanks for your help0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions