Type Conversion Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lou Early
    New Member
    • Nov 2010
    • 5

    Type Conversion Error

    When attempting an update query as follows.

    Field: ROW_Cost_Acre
    Table: Greene_County_P roperty
    Update To: [ROW_Actual_Cost]\[ROW_Acres]

    I get a type conversion error. It calculates the correct value for some of them but the other get a type conversion error. This same query works fine in another database for another county with no problem.

    The query is calculating the cost per acre from the total cost field and the total acres field and then placing it in the cost per acre field.
  • gnawoncents
    New Member
    • May 2010
    • 214

    #2
    Lou,

    Do you have any zeroes or nulls in your values? Also, what data type are you using for the three fields in question?

    Comment

    • Lou Early
      New Member
      • Nov 2010
      • 5

      #3
      There are no Null values and all three fields are formatted as numbers. There are 21 total rows and the query works properly and updates 15 of those rows but returns the error on the remaining 6.

      Comment

      • BRawn
        New Member
        • Jul 2010
        • 28

        #4
        Hi Lou,

        Could you perhaps post the query you're trying to execute?
        It'll give us a good idea of what you're trying to do and we can try and help you from there...

        Comment

        • Lou Early
          New Member
          • Nov 2010
          • 5

          #5
          Screen Shot

          UPDATE Greene_County_P roperty SET Greene_County_P roperty.ROW_Cos t_Foot = [ROW_Actual_Cost]\[ROW_Length], Greene_County_P roperty.ROW_Cos t_Acre = [ROW_Actual_Cost]\[ROW_Acres]
          WHERE ((([Greene_County_P roperty]![ROW_Aquired])="T" And ([Greene_County_P roperty]![ROW_Aquired])="T"));
          Attached Files

          Comment

          • gnawoncents
            New Member
            • May 2010
            • 214

            #6
            Kind of an odd question, but are any of your ROW_Acres 0.5 or less?

            Comment

            • gnawoncents
              New Member
              • May 2010
              • 214

              #7
              One other thing, is there any reason you're using the back-slash (\) for division as opposed to the forward-slash (/) for division? I ask because everything might just work fine if you switch to the forward-slash.

              Comment

              • Lou Early
                New Member
                • Nov 2010
                • 5

                #8
                Well that was dumb

                Yeah. It was the \ instead of /. I cant believe I overlooked something so stupid. Sorry to waste everyone's time.

                Comment

                • OldBirdman
                  Contributor
                  • Mar 2007
                  • 675

                  #9
                  When I first read this post, I noticed the integer divide "\" and assumed this was what was wanted, as Cost-per-Acre might very well be expressed as a whole number of dollars. A quick check of Access Help revealed that both handled Null and Empty fields the same, So I didn't see the solution.
                  gnawoncents' question "...are any of your ROW_Acres 0.5 or less?" is the key. Access rounds each numeric expression BEFORE dividing. So 0.5 is rounded to 0, and the divide fails.
                  Some quick testing reveals some quirks, so I now know to be very careful with this operand or NOT USE IT at all. In Immediate Window:
                  Code:
                  ?5.7\2.2
                   3
                  ?INT(5.7/2.2)
                   2
                  ?FIX(5.7/2.2)
                   2
                  
                  ?5.7\-2.2
                   -3
                  ?INT(5.7/-2.2)
                   -3
                  ?FIX(5.7/-2.2)
                   -2

                  Comment

                  Working...