Update the current textbox with new Data
guidorobben
Member Posts: 157
I have a textbox where I can fill in the lastname of a user. I thought it would be cool if a users fills in his initials and prefix and lastname that this would be automaticly split. So I build a codeunit that does this.
I can asks all these Items from the Codenit. If I use my name as an example I would get
Initial := 'G.'
LastName := 'Robben'.
The problem I have here is that I'm fillin in the complete name in the Textbox of the lastname. I can set all the other values I get returned. But when I try to set the Lastname nothing happens, I never updates the value I set.
The textbox has as sourceexpr 'Lastname'. So I try to set this one. No luck either. I use the OnAfterInput to start the splitting.
Does anybody have an idea how to solve this. Btw is the best place to do this on the form, or should I put this in the Table Triggers??
Regards,
Guido
I can asks all these Items from the Codenit. If I use my name as an example I would get
Initial := 'G.'
LastName := 'Robben'.
The problem I have here is that I'm fillin in the complete name in the Textbox of the lastname. I can set all the other values I get returned. But when I try to set the Lastname nothing happens, I never updates the value I set.
The textbox has as sourceexpr 'Lastname'. So I try to set this one. No luck either. I use the OnAfterInput to start the splitting.
Does anybody have an idea how to solve this. Btw is the best place to do this on the form, or should I put this in the Table Triggers??
Regards,
Guido
0
Comments
-
Well, to be honest, you should do nothing. Just let the user enter initials in "Initials" field and last name in "Last name" field.
The only thing that the user must do additionaly is to press enter or arrow down, etc. (depends on the fields layout).
And it is much more simpler and intuitive to use !®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
It is always the best choise is to place code in tables because it will be used in all forms (do in OnValidate triger). If you want to have this feature only on this form, you add this code to OnValidate triger in this field object.0
-
Just put some code to onValidate trigger of "Last Name" that's it -
it's too small to use a codeunit for this.
I made you an example for splitting field "Last Name" to
"First Name", "Middle Name" and "Last Name"
//TK ->
//If user wants to fill fields separately
IF "First Name" = '' THEN
BEGIN
//This is optional - you can keep the dots
"Last Name" := DELCHR("Last Name",'=','.');
//check if more than one name is inserted
IF STRPOS("Last Name",' ') <> 0 THEN
BEGIN
"First Name" := DELSTR("Last Name",STRPOS("Last Name",' '),99);
"Last Name" := DELSTR("Last Name",1,STRLEN("First Name"));
"Last Name" := DELCHR("Last Name",'<',' ');
IF STRPOS("Last Name",' ') <> 0 THEN
"Middle Name" := DELSTR("Last Name",STRPOS("Last Name",' '),99);
//nothing is cut if Middle Name is zero
"Last Name" := DELSTR("Last Name",1,STRLEN("Middle Name"));
"Last Name" := DELCHR("Last Name",'<',' ');
END ELSE;
END;
// <-
Maybe this is helpful.
And to choose between a form and table - it's easier to find code from table than to look in every control - still sometime you wan't some form acting differently.
Tõnu0 -
I still think from users point of view it's best not to do the "auto splitting".
What if user reverses entry of first name and last name ? He must learn the correct order.
What if he makes a mistake in Last name and he goes to correct it ?
What if he makes a mistake in First Name ? Must he always type the whole name ?
What if his last name is something like "Van Der Saar" ?
Check in MS Outlook, even they are not allways smart enough...
But of course this is only my opinion. The choice is only yours. No hard feelings.®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
This is the way I do the autosplitting. I created an array and in there I put every word in a deifferent index. After this I give every word a Context depending on it's value and location in the string. So "van der saar" will be no problem. All the words I don't know will become the lastname.
At the moment I'm new with Navision. So i'm trying to build something and see where I ran into problems. I'm used to working with Delphi and VB & VBA. So there are a lot of things that are different. I'm trying to find out what... This was one of these things...0
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 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