Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99

    Turn Off Automatic Rounding in Access

    Hi,

    I am using Access 2016. I have a form with an Item_Number field where values need to be entered into tables as decimals. I do not want Access to round my decimals for me because sometimes I may need to type in, for example, the number 5.1, but other times I may need to type in 5.10. In my table where this field is stored, I have the field size set to double and the decimal places set to auto. In the form where the user types in the value, I have the decimal places set to auto and the format set to fixed. Currently, if I type in the number 5.1, it automatically sets it to 5.10. I have messed around with the decimal places setting, field size, and format to try and fix this, but it seems like no matter what, Access either rounds 5.1 to 5.10 every time, or it will round 5.10 to 5.1. Is there a setting that will allow the user to type in whatever they want to type in without Access rounding anything?



    Thanks!

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Note that is not rounding at all. 5.1 and 5.10 are exactly the same values, it is just the number of decimal places that are shown. What you are referring to is Formatting (how many decimals to show).
    For a number, a zero at the end of any decimal really has no meaning. It doesn't add/change anything to the value. As such, most systems automatically drop trailing zeroes in a decimal for numeric entries.
    What you are referring to is Formatting (how many decimals to show).

    In storing a numeric entry, Access will automatically drop any trailing zeroes after the decimal, regardless of how you enter it. If you want to maintain trailing zeroes, then you need to enter the values as Text, not Numbers (where all characters are retained). Of course, if you are hoping to apply mathematical functions on these entries, that could be problematic. However if you are not, this may work for you.

  3. #3
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Ah, I see. I do not have to do any mathematical operations, so this is working for me. thank you so much!

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome.

  5. #5
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    @JoeM, scratch that. I have some buttons that navigate between forms, and I have conditions set on those buttons that will filter the next form by the item number. After changing the item number field to a short text, when I click on one of the buttons to navigate to a different form, I get an error that says "Data type mismatch in expression". I am thinking this is because the item number field is no longer a number. Any way to fix this?

  6. #6
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If you change the Data Type, you may need to rebuild any code that uses that field.
    If you have placed those fields on your Form, you will need to replace that field with the new version (just delete the original field, and then re-add it from your list of available fields).

  7. #7
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    I will try that. Thank you!

  8. #8
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Hi again. I tried what you said, and I am still receiving the same error. To give you some background on my database, I am using it to track orders from customers. The parts that the customer orders must be inspected before being shipped out. So, two of my forms are specifically for the inspection process. The first form allows the user to choose which order to inspect, and the second form is the actual inspection form. Here is a picture of the first form, where the user chooses which order to inspect:
    Click image for larger version. 

Name:	Annotation 2019-06-05 154320.jpg 
Views:	17 
Size:	110.2 KB 
ID:	38632

    When the user selects the command button next to an order, I have macros running in the background of the button that will filter the succeeding form based on the order number and item number of the selected order. Here is a picture of the macros:
    Click image for larger version. 

Name:	Annotation 2019-06-05 154534.jpg 
Views:	16 
Size:	30.0 KB 
ID:	38633

    Then, after selecting the button, this screen should appear with info about the selected order:
    Click image for larger version. 

Name:	Annotation 2019-06-05 154355.jpg 
Views:	16 
Size:	87.8 KB 
ID:	38635

    However, since I changed the data type of the item number field, every time I click the command button, I get this error:
    Click image for larger version. 

Name:	Annotation 2019-06-05 154337.jpg 
Views:	16 
Size:	21.8 KB 
ID:	38636

    I even tried changing the order number field to a short text as well, and I am still getting the error, and as a result I cannot navigate to the next form. Is there anything else I could try, or is there another way to fix the decimal issue without changing the data type of the item number field?
    Attached Thumbnails Attached Thumbnails Annotation 2019-05-22 113647.png  

  9. #9
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    And, I deleted and re-added the fields from the form, hence why those fields' text boxes are so much smaller than the rest

  10. #10
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I think the issue is with the WHERE command of your Imbedded Macro. When searching on Text fields, you must have text qualifiers around the values you are looking for. So instead of looking for:
    5.1
    you would be looking for
    "5.1"
    or
    '5.1'
    (SQL will usually accept either single or double-quote for text qualiferis).

    So you need to change the part of your WHERE clause that says this:
    =="[Order_Number]=" & [Order Number] & " AND...
    to this:
    =="[Order_Number]='" & [Order Number] & "' AND...
    (so note the two single-quotes in red that I added).

  11. #11
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Is this assuming that both the Order Number and Item Number fields are short text data types? Also, do I need to add the single quotes around the portion of the macro that is for the Item Number field?

  12. #12
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Any text data field will need text qualifiers around the value it is returning for that condition.

  13. #13
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Okay, that seems to be working. Now, if I have a macro button filtered only by the Item Number field (like this: ="[Item_Number]="&[Item_Number] ), where would I add the single quotes?

  14. #14
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Same places as the last (should follow the exact same structure as the other one I showed you).

  15. #15
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Where you put your text identifiers assumes there are two fields involved in the macros. I only have one field, so the syntax is different. Would the text identifiers go here: ='"[Item_Number]="' & [Item_Number] ? I cannot put text identifiers around the second Item_Number in the same manner you did because there is no & or " that come after the second Item_Number

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Rounding a number in access
    By xmattxman in forum Queries
    Replies: 4
    Last Post: 08-07-2018, 02:45 PM
  2. Turn of security warning in Access
    By jaryszek in forum Access
    Replies: 5
    Last Post: 07-30-2018, 03:13 PM
  3. Replies: 1
    Last Post: 06-07-2018, 08:05 AM
  4. Turn Screen Updating off and on in Access
    By Paul H in forum Access
    Replies: 6
    Last Post: 08-28-2012, 09:45 AM
  5. Turn OFF Warnings in Access 2010
    By taimysho0 in forum Programming
    Replies: 3
    Last Post: 01-27-2012, 05:47 PM

Tags for this Thread

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