Results 1 to 4 of 4
  1. #1
    Mick99 is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    58

    Counting the Number of Decimals in a query field

    Hi All, Just wondering if someone can help with the issue of being able to count the number of decimal points within a field. I can count the number of Chars with the use of the Len function but I am unable to count just the decimals. To give a clear picture of what I am trying to acheive, I am needing to use the decimal points as the key in defining the level of the item number as I can not rely on a char lenght alone. My table = tbl itemdata and the field = itmenumber. Any help would be greatly appreciated.



    1 decimal point = "MAIN" 2 decimal points = "SUBITEM" and 3 decimal points = "SUBSUBITEM"

    1.0 = MAIN
    1.1 = SUBITEM
    1.1.1 = SUBSUBITEM


    Cheers Mick

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    Len(Field) - Len(Replace(Field, ".",""))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Mick99 is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Jul 2015
    Posts
    58

    Thumbs up

    Quote Originally Posted by pbaldy View Post
    Try

    Len(Field) - Len(Replace(Field, ".",""))

    Brilliant thank you so much it works a treat.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Format field to show 2 decimals
    By takara in forum Forms
    Replies: 13
    Last Post: 06-04-2015, 03:18 PM
  2. How to hide decimals in the form field
    By azhar2006 in forum Forms
    Replies: 20
    Last Post: 01-25-2014, 01:40 PM
  3. Replies: 21
    Last Post: 11-07-2012, 02:14 PM
  4. Replies: 3
    Last Post: 05-12-2012, 04:52 AM
  5. Number of decimals in sum function
    By arfo in forum Access
    Replies: 6
    Last Post: 12-02-2010, 09:08 AM

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