Showing an Error message if "No." less than seven.

FreakyFreaky Member Posts: 125
Hi Guys,
I have a field name "No." on a Form and I want to use this Form to insert a new number into the table the form looks to. The number should have seven digits and if less than seven I want to have a window with an error message.When I click OK it should CLEARALL .The field "No." is of data type code. My problem is that I don't know how to code that.

Thanks for help.

Comments

  • ssinglassingla Member Posts: 2,973
    Define a variable say length with data type integer. Write the follwing code on the "on validate" trigger of the field

    length := STRLEN("No.");
    if length <7 then error ('Your Message')
    CA Sandeep Singla
    http://ssdynamics.co.in
  • krikikriki Member, Moderator Posts: 9,110
    In the OnValidate-trigger of the field in the table, put something like this:

    IF STRLEN("THe Field") <> 7 THEN
    FIELDERROR("THe Field",'The length should be 7');
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    edited 2008-09-08
       If (STRLEN("No.") < 7) then Begin
         Message('The No. length is less thah 7');
         "No." := '';
       End;
    
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • DenSterDenSter Member Posts: 8,305
    That only catches if it is less than 7 characters, what happens if it is MORE than 7?
    IF NOT (STRLEN("No.") = 7) THEN
      ERROR('you must have 7 characters');
    
  • SavatageSavatage Member Posts: 7,142
    edited 2008-09-08
    DenSter wrote:
    That only catches if it is less than 7 characters, what happens if it is MORE than 7?

    Actually the orig Post doesn't specify that it has to be 7 just "at least" 7.

    How about
    IF NOT (STRLEN("MyField")=<7) THEN
      IF NOT CONFIRM('%1 is normally at least 7 digits, use this number anyway?',FALSE,FIELDNAME("My Field"))
      THEN ERROR('Nothing Changed.');
    

    :lol: we can probably write 100 versions of this code :lol:
  • ara3nara3n Member Posts: 9,256
    Let's see if we can actually accomplish 100 different ways?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • SavatageSavatage Member Posts: 7,142
    Seriously? :mrgreen:
    IF (STRLEN("MyField")in [0,1,2,3,4,5,6]) THEN
      IF NOT CONFIRM('%1 is normally at least 7 digits, use this number anyway?',FALSE,FIELDNAME("My Field"))
      THEN ERROR('Nothing Changed.');
    

    Well there can be a bunch of sight tweaks as above :whistle:
  • kinekine Member Posts: 12,562
    Savatage wrote:
    Seriously? :mrgreen:
    IF (STRLEN("MyField")in [0,1,2,3,4,5,6]) THEN
      IF NOT CONFIRM('%1 is normally at least 7 digits, use this number anyway?',FALSE,FIELDNAME("My Field"))
      THEN ERROR('Nothing Changed.');
    

    Well there can be a bunch of sight tweaks as above :whistle:

    Or more "geek" condition:
    IF (STRLEN("MyField") DIV 7) = 0 THEN
      ...
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.