Results 1 to 6 of 6
  1. #1
    cowboy is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Posts
    291

    Format number conditionally on decimal ??

    I have a form with a control source =[Amount]
    I am currently using the format 0.##

    Problem is if the number is a whole number for instance 2, it will show up with a decimal after it like
    2.



    Is there a way to make it so if it is a whole number then it wont display a decimal?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    That looks like an Input Mask. It requires the textbox to display decimal.

    If Amount is a field in the form's RecordSource the = sign is not needed.
    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
    cowboy is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Posts
    291
    Sorry June, I must not have been very clear. These images might help
    The first is my textbox properties and the second is the results I am getting.
    Click image for larger version. 

Name:	txtbox.jpg 
Views:	19 
Size:	20.2 KB 
ID:	13114 Click image for larger version. 

Name:	result.jpg 
Views:	19 
Size:	2.1 KB 
ID:	13115

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    I have never used the Format property with that sort of parameter. It seems more appropriate for InputMask. Did you try removing it?
    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
    cowboy is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Posts
    291
    You mean something like this?
    Click image for larger version. 

Name:	txtbox2.jpg 
Views:	6 
Size:	24.7 KB 
ID:	13122
    If I use those settings my results dont seem to follow the decimal places rule for some reason.
    Click image for larger version. 

Name:	result2.jpg 
Views:	9 
Size:	6.2 KB 
ID:	13123

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    Need something in the Format property. If you use a Format parameter from the dropdown like Fixed you will get rounded display with the number of decimals specified in DecimalPlaces. If you don't want the decimals to show when the value is a whole number, that would require an expression in the ControlSource and the textbox would not be editable or VBA code to modify the value, both result in a text value. However, it is mathematical convention for all values of an attribute to be displayed with the same precision.
    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. Table Number format and decimal place problem
    By DjMorgan in forum Access
    Replies: 3
    Last Post: 04-29-2013, 01:52 AM
  2. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  3. Replies: 3
    Last Post: 03-12-2012, 01:23 PM
  4. Replies: 0
    Last Post: 01-30-2012, 01:20 PM
  5. Format decimal numbers with fixed width
    By Persist in forum Programming
    Replies: 5
    Last Post: 07-14-2010, 05:43 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