Set focus to a specific field if criteria not met

ireneg
Member Posts: 30
Hi there
I want to test on the modify event of a table if a value entered is valid, if not I want to set the focus back to that field containing the invalid value and don't allow user to continue, unless he cancel the entry. The error statement causes a rollback and the all will be lost, so this is not a solution.
Is the something in Navision that I can use similar to Foxpro's "setfocus" command?
Thanks
Irene
I want to test on the modify event of a table if a value entered is valid, if not I want to set the focus back to that field containing the invalid value and don't allow user to continue, unless he cancel the entry. The error statement causes a rollback and the all will be lost, so this is not a solution.
Is the something in Navision that I can use similar to Foxpro's "setfocus" command?
Thanks
Irene
Irene Grassow
0
Answers
-
Hi,
What happens if you put your validation code in the OnValidate trigger of the field ?
Regards,
dkone.0 -
If the "Security Obtained" column contains "Legally in place" then the "Date Obtained" must contain a date. if the user enters over the "Obtained date" without changing or entering a value, the validate event does not take place. Also, I need to force the cursor to stay in the "Date Obtained" field of the record that is not valid.
So, when the criteria is not met or the field is empty, a message must be displayed and the focus must stay on that field.
Is this possible in Navision?
ThanksIrene Grassow0 -
Hi,
You can Use Activate/Deactivate trigger on form to catch when user leaves a field.
Something like this :"Security Obtained" - OnDeactivate IF "Legally in place" THEN "Date Obtained".Activate "Date Obtained" - OnDeactivate Validation Code.
But validation code should be on table not on form.
Regards.
Dkone.0 -
I've tried the 'activate' command, but I'm getting an error "A variable is not a record".
Date Signed - OnDeactivate if (Obtained = Obtained::"Legally in place") and ("Date Signed" = 0D) then begin message('you have to enter a date signed'); "Date Signed".activate; end;
I've placed all my other code on the table instead of the form, but cannot find a way to force a field to keep the focus.
ThanksIrene Grassow0 -
I've placed the CurrForm infront of the field.activate and that fixed the error, but the focus is still placed on the next field. it does not stay on the Date Signed field.
Surely there must be something in Navision that allows you to manipluate the focus.
ThanksIrene Grassow0 -
You can put code that activates your field on each other OnActivate of the form.
But if i where you, i'll do it in another way, more "Nav compliant".
Trying to set and force focus is not the best solution : if you put your logic in the form what about an record created outside this form (by a report, a dataport,... ).
Some other ways :
- Put a boolean field "Validated" on your table that should be true to make the record ok. Put your validation code in the OnValidate of this field.
- Look at the "DelayedInsert" property on a form, and put validation code on "OnInsert Trigger"
- You can also look for 'mandatory fields' in this forum for further informations.0 -
ireneg wrote:I want to test on the modify event of a table if a value entered is valid, if not I want to set the focus back to that field containing the invalid value and don't allow user to continue, unless he cancel the entry.
Irene
Irene,
Don't do this.
Train the users to do it the Navision way. Ask them why they bought Navision in the first place. If they need FoxPro functionality they should have had a custom system developed in FoxPro.
You are heading down a very long and dangerous path this way.
<edit - added the quote to make it clear what I am replying to>David Singleton0 -
0
-
ireneg wrote:I've placed the CurrForm infront of the field.activate and that fixed the error, but the focus is still placed on the next field.Kai Kowalewski0
-
dkone wrote:
:?: :?: :?: :?:
My post was addressed to Irene, not you.
OK I edited my original post to make it more clear. Sorry for the confusion.David Singleton0 -
I've decided to stick to Navision standards. I've added a new column, 'Error = boolean', which is populated on the OnModify trigger of the table. This way the form can indicate to the user which records are invalid and it is up to the user to fix them.
Thanks for all you help!
IreneIrene Grassow0 -
ireneg wrote:I've decided to stick to Navision standards. I've added a new column, 'Error = boolean', which is populated on the OnModify trigger of the table. This way the form can indicate to the user which records are invalid and it is up to the user to fix them.
Thanks for all you help!
Irene
=D> =D> =D> =D> =D> =D>
Excellent decision.David Singleton0 -
ireneg wrote:I've decided to stick to Navision standards. I've added a new column, 'Error = boolean'
Just a comment. Don't call your field "Error", give it some other name.
If you call it Error, you wont be able to trow an ERROR on the table, because it confuses the field with the command.
Salut!Laura Nicolàs
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.0 -
Thanks, I will change the field name.
IreneIrene Grassow0
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