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
0
Comments
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 !
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
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õnu
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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
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...