Update the current textbox with new Data

guidorobbenguidorobben 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

Comments

  • RobertMoRobertMo Member Posts: 484
    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           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • i4tosti4tost Member Posts: 208
    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.
  • facadefacade Member Posts: 57
    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õnu
  • RobertMoRobertMo Member Posts: 484
    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           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • guidorobbenguidorobben Member Posts: 157
    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...
Sign In or Register to comment.