Results 1 to 3 of 3
  1. #1
    Tascja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2017
    Posts
    4

    MOD formula not working correctly

    Hello,
    I'm having an issue with the MOD formula. I need to convert a height in centimeters to feet and inches, with the Ft and In reported as separate fields. I use the following steps:

    Field 1: Ht(in): [Ht(cm)]/2.54 - gives me height in inches
    Field 2: HeightFT: Int([Ht(in)]/12) - gives me height in feet rounded to a whole integer
    Field 3: HeightIN: [Ht(in)] Mod 12 - gives me the remainder of inches from height in feet

    This works 99% of the time. I found it doesn't work for values that are close to a whole value in feet (ie. 3 ft 11.8 in, 4 ft 11.9 in).

    For the following values the above steps don't work:


    152 cm : this is reported as Field 2: 4 Ft and Field 3: 0 In (Because the remainder is 11.8 it gets rounded to 12 and then there is no longer any remainder from 12)
    121 cm : this is reported as Field 2: 3 Ft and Field 3: 0 In (Because the remainder is 11.6 it gets rounded to 12 and then there is no longer any remainder from 12)

    How do I stop Field 3 from rounding the remainder? Or does anyone have any other suggestions on how I can get the Height from Centimeters to Feet and Inches accurately.
    Thanks in advance for any help!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    If you want to eliminate use of MOD:

    Feet: Int([Ht(cm)]/2.54/12)

    Inches: ([Ht(cm)]/2.54/12 - Int([Ht(in)]*2.54/12)) * 12
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Tascja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2017
    Posts
    4
    Thanks for your suggestion! I'll try it out and see if it eliminates the issue.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Age Parameters Not Working Correctly
    By MatthewR in forum Queries
    Replies: 1
    Last Post: 02-25-2016, 03:38 PM
  2. WHERE not working correctly?
    By aellistechsupport in forum SQL Server
    Replies: 5
    Last Post: 01-02-2016, 04:24 AM
  3. Sort function not working correctly
    By kristyspdx in forum Reports
    Replies: 2
    Last Post: 10-09-2012, 11:04 AM
  4. Condtion not working correctly
    By hawkins in forum Access
    Replies: 3
    Last Post: 09-07-2011, 02:59 PM
  5. Search field is not working correctly
    By jakeao in forum Programming
    Replies: 9
    Last Post: 05-18-2009, 07:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums