3 Replies Latest reply on Mar 16, 2009 4:47 PM by CountryBoy1

    calculation problem for text

    CountryBoy1

      Title

      calculation problem for text

      Post

         Been away from Filemaker Pro 9 for several weeks.  Tried to set up

      a field that looks at the City Name in another field and uses a

      calculation (Case statement) to come up with a Zip Code.  Can only

      get it to work for the first City Name.  Zip Code is defined as text.

          When should a field type be defined as a "calculation" and when should

      it not be ?  Tried it both ways, having Zip Code as a "text" field that

      uses a calculation and having it as a type "calculation" that uses a calculation.

      Have the same problem both ways.

         Thanks for your help.

       

       

        • 1. Re: calculation problem for text
          obeechi
            

          If you have a lot of zip codes, a case () approach might not be the best way to do it. When you want to be able to edit a text field (like for corrections) then you don't want to use Type: Calculation for that field's definition

           

          Model after this (and if using a Type: Text field with an Auto Enter calculation then deselect "Do not replace ...")

            Case ( name = "mark" ; "good" ; name = "frank" ; "okay" ; "not so good" ) // "mrka" will return "not so good"

             # Case ( test1 ; result1 {; test2 ; result2 ; ... ; defaultResult} ) 

           

          A non-case () approach might involve a match of records between two tables based on zip code.  

            

          If someone is entering "Los Angeles, CA 90008" into your cityField then you need to fire or retrain them. "CA" belongs in the stateField et ... 

          • 2. Re: calculation problem for text
            philmodjunk
              

            I suggest you paste your calculation fields definition expression into your message so we have a better chance at helping you. You also should give us an idea as to what tables are involved.

             

            Your Post says: "Can only get it to work for the first City Name." That implies that your city names might be in a different table from your calc field or that you are storing city names in a repeating field.

            • 3. Re: calculation problem for text
              CountryBoy1
                

              Dear PhilModJunk:

                       I finally realized that the problem HAD to be in the case statement.  What I

               had was

                             Case( (City_Addr= "Name1") ;

                                        "12345" ;

                                                      ("Name2") ;

                                         "23456" ;

                                                      ("Name3") ;

                                            etc....

                Instead, I should have had the "City_Addr=" in each new case.  I thought the

               case would pick up that it was to test City_Addr for each case, when, in fact, it

               must be defined for each case.  Thanks for your help.

               

                            Sincerely, CountryBoy1