Results 1 to 5 of 5
  1. #1
    Deutz is offline Advanced Beginner
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    51

    Percent textbox unusual behaviour

    Hi and thanks in advance,

    I am using Access 2003 and have some unbound textboxes formatted as percent with zero decimal places. I have code for each textbox in the After Update event which divides the textbox value by 100 so that the correct values are displayed to the user. So if the user enters 100 then they see 100% rather than 10000%.

    The strange thing is that for certain numbers the underlying decimal value is displayed when I click back in the textbox. For instance, if I enter 70 then 70% is displayed as required but when I click back in the textbox the 70% changes to display the underlying value of 0.7. This behaviour only happens with 10 numbers out of the range: 1 to 100. The numbers are: 35, 41, 47, 57, 69, 70, 82, 83, 94, 95. All the other numbers in the range remain as the number followed by the percent sign when I click back into the textbox.

    As I will be saving the underlying fractions to a table, I don't want values displaying and rounding like this. For instance, if I enter 70 and then click back on the textbox then the 70% will change to 0.7. I can then edit that value to something like 1.5 which will then round and display as 2% when the textbox loses focus. If I then click back on the text box, the underlying value displays as 1.5% which rounds up to 2% due to the textbox being formatted with zero decimal places. Unfortunately, the underlying value of 0.015 will be saved rather than 0.02 which actually equates to what is displayed in the textbox.



    Any ideas on what I can do to control this behaviour?

    Regards
    Michael

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    I didn't follow the specifics of your post; but willl give this generic input:

    up thru 03 - the definition of % is such that for many applications people found it not intuitive and add a divide/100 in the after update event - so that it displays a % as one expects....one would put in 2 and get 200% ; so you needed to /100 in order to get 2% which is what alot of people intuitively wanted in the first place...

    MS decided in 07 and beyond they changed it to agree with the general understanding of how it should behave and so changed it so the /100 is no longer needed.

    So that's part 1. Part 2 is that there are 2 levels of control; the table field property and the form control property. So just be sure that you consider both levels in resolving your issue.

    Hope it helps.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Hi NTC

    Quote Originally Posted by NTC View Post
    MS decided in 07 and beyond they changed it to agree with the general understanding of how it should behave and so changed it so the /100 is no longer needed.
    Hope it helps.
    If you developed something using A2003 and a user opened the file with A2007 would it work correctly?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    the /100 method will be an issue for 03 designs that migrate forward....one needs to deactivate the /100 code in 07+ FEs.



    the poster's issue is involving the mismatch of the field properties between the 2 levels (mismatch in the sense of display not being to user's expectation)....probably involving the number of digits. it can get confusing.

  5. #5
    Deutz is offline Advanced Beginner
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    51
    Thanks for your replies.

    I think I will just do away with the percent format as it is more trouble than it is worth and just use a Fixed decimal format and convert the value to a fraction when I save to a table and convert back when I load the textboxes from the table.

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

Similar Threads

  1. how to calculate Percent in an update query?
    By newtoAccess in forum Queries
    Replies: 4
    Last Post: 11-23-2010, 10:11 AM
  2. workinkg hours by percent
    By Mosely in forum Queries
    Replies: 1
    Last Post: 11-01-2010, 09:32 AM
  3. Percent Change between months by group
    By P5C768 in forum Queries
    Replies: 3
    Last Post: 09-15-2010, 06:59 PM
  4. Odd Form Behaviour
    By FrankHelbert in forum Access
    Replies: 1
    Last Post: 03-13-2010, 04:56 PM
  5. Qurey on two ODBC Tables Strange behaviour
    By tingletangle in forum Queries
    Replies: 1
    Last Post: 01-14-2010, 03:40 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