7 Replies Latest reply on Nov 6, 2012 1:14 AM by keitho

    Format a Registration Number

    keitho

      Hi All

       

      I am looking for a quick & simple way of formating a vehicle registration number i.e. SY23 777

        • 1. Re: Format a Registration Number
          beverly

          k, what is the PATTERN (is it the same every time "AA## ###"?) or is it variable?

          i.e. SY23 777

           

          Beverly

          • 2. Re: Format a Registration Number
            keitho

            Hi Beverly

             

            This is the standard format for new registration numbers SY23 777

             

            Some older registrations were formated Y### ### i.e Y563 AAA

             

            And then we get the personalised Plates which could be anything (not realy looking to format these)

             

            mainly I am looking for 3 digits from the right then a space

             

            I have found the RIGHT format but then don't know how to put the space in after the 3rd digit

             

            Thanks

             

            Keith

            • 3. Re: Format a Registration Number
              rob.speakman

              Hi Keith,

               

              You could use this calculation;

               

              Let(

              [

              numberplate = "SY23777" // put the number plate field in here

              ];

              Left (numberplate ; 4) & " " & Middle(numberplate ; 5 ; Length(numberplate))

              )

               

              Will return the result "SY23 777".

               

              Best,

               

              Rob

              We Know Data

              • 4. Re: Format a Registration Number
                Steve Wright

                Something along these lines should do the trick and cater for a few variations.

                 

                 

                let ([

                          reg = trimall(registrationField ; 1 ; 3);

                          ln = length ( reg)

                ];

                 

                 

                 

                 

                          case (

                                    ln = 5 ; left ( reg ; 2) & " " & right(reg ; 3) ;

                                    ln = 6 ; left ( reg ; 3) & " " & right(reg ; 3) ;

                                    ln = 7 ; left ( reg ; 4) & " " & right(reg ; 3) ;

                                    reg

                          )

                 

                 

                ) //end let

                • 5. Re: Format a Registration Number
                  keitho

                  Hi Rob & Steve

                   

                  I am new to FileMaker Pro

                   

                  Do I use your script to create a 'Custom Function' and apply it to my RegNo field or do I use it to create an OnLoad script that checks the RegNo field Format

                   

                  Sorry to apear thick

                   

                  Keith

                  • 6. Re: Format a Registration Number
                    comment

                    keitho wrote:

                     

                    mainly I am looking for 3 digits from the right then a space

                     

                    Try it this way (attached)?

                     

                     

                    keitho wrote:

                     

                    And then we get the personalised Plates which could be anything (not realy looking to format these)

                     

                    How can one tell a personalized plate from the rest?

                    • 7. Re: Format a Registration Number
                      keitho

                      Thanks to everyone who replied to my query

                       

                      Using bits of everyones input, I have got a solution, thanks to Michael for showing me where to put the script

                       

                      Keith