Results 1 to 14 of 14
  1. #1
    takara is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    9

    Format field to show 2 decimals

    I have a multiple items form that shows qty to build for productions orders.



    if there are 2 to build it shows 2.000000000000000

    that is the data stored in the sql table

    I've tried changing the format to standard or #,##.00 and decimal places of the field property to 2

    doesn't do anything. Not sure if this is because the table is linked to sql or not, but want to format the data to only show 2 decimals or possibly whole numbers.

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,444
    where are you setting the format? if in a linked? table or query, that format will not be passed to a form or report, you'll need to set it there.

  3. #3
    takara is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    9
    I'm setting it on the form.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    That looks like InputMask property template. Need to set the Format and DecimalPlaces properties.
    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.

  5. #5
    takara is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    9
    isn't the input mask for input information... my fields already have information and I want them to be displayed properly... I don't see an option in input mask for displaying numbers either.. (figured I would try it)

    I have decimal numbers like 2.0000000000000 that are already in the table and I want to display 2 or 2.00

    the format and decimal places properties have no effect for some reason

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    Well, Access doesn't hold onto trailing zeros in number fields in tables. But you say this is a linked SQL table? Seems Access is not recognizing it as a number field. Maybe need to convert the value. Try Int() or CDbl().
    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.

  7. #7
    takara is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    9
    I could convert the value if I was managing the info in VB, but it's just populating the fields on the form from the table, is there a way to convert the number to integer in the properties of a field on a form?

  8. #8
    takara is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    9
    your right, when I view the table design via Access (read-only), the data type is short text not integer.

    wondering if there is a way to tell the field to handle the text as an integer.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    I don't know if that can be done when setting the link. I don't have enough experience with SQL. What is the field type in the SQL table (not the link, the actual table)?
    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.

  10. #10
    takara is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    9
    decimal(38, 20) or decimal precision 38, scale 20

    precision is the total number of digits, scale is the number of digits right of the decimal point.

    eg. the number 2354.234 has a precision of 7 and a scale of 3

    obviously access doesn't recognize this and converts it to short text... can't figure out how to display this properly

  11. #11
    IrogSinta is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jun 2015
    Posts
    103
    You can either use a textbox on the form with the expression:
    =Format(VAL(Qty), "#,###.00")
    Or
    =VAL(Qty) and put the formatting in the Format Property of the textbox.

    However if you intend to do any calculations with this qty, you are better off creating a query based on the table and adding a calculated field using VAL(Qty) in the expression. You can then base your form off of this query and you will be able to apply a format property to the new field. This is the more practical route since you may eventually want to create reports and sum your quantity.

  12. #12
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Quote Originally Posted by takara View Post
    decimal(38, 20)
    Your problem is likely related to the fact that Access cannot handle Decimal Numbers with a precision greater than 28. So it's being converted to a text string. I haven't ever tried something like that before, but I would imagine Access would have trouble updating the value as well (since it might be returning a string to SQL Server instead of a number)?

    If you're only worried about displaying the number or if you can update it just fine, try change the Format Property of your Form Control to "Fixed" and the Decimal Places Property to "2".

  13. #13
    takara is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    9
    IrogSinta,

    Thanks so much. I've hidden the original text box that holds the decimal value as a string, and shown a new text box that converts the datatype (val()) as you suggested... works a charm.

    the only solution I could think of last night was to create a View in SQL of the data needed and ensure the decimal value was in a format Access could manage (most likely would truncate some precision, but who needs that much anyway)

    Rawb,

    Not using access to update the tables so this is not a problem. Strictly used to read tables and display and interact with information in a more user specific setting rather than rolling out a NAVISION client to each person (and cheaper).

    Changing the format property of the form control to fixed isn't an option as Access doesn't recognize it as an integer.

    Thanks for all the responses, problem solved.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    Bind the control to alias field that converts the text to number.

    Or expression in query or textbox ControlSource: Format([fieldname], "0.00")

    The value is still text string which means if need to be used in subsequent calcs will still have to convert to number.
    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.

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

Similar Threads

  1. Show field in a different format
    By medusa3604 in forum Queries
    Replies: 1
    Last Post: 01-24-2015, 06:36 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: 4
    Last Post: 03-12-2013, 06:49 PM
  4. Export to .txt Issue: Field Returning 2 Decimals
    By SoSubaruMe in forum Import/Export Data
    Replies: 0
    Last Post: 02-27-2012, 09:09 AM
  5. Replies: 2
    Last Post: 03-23-2011, 11:43 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