Results 1 to 3 of 3
  1. #1
    AmanKaur123 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    47

    Display textbox value with percent format


    Hi All

    I have a textbox with Format "Percent". Now If I type in 90 in the textbox and display the message using below code then it displays 0.9 . why not 90% and also how vcan I store 90% in the field in the table?
    Code:
    msgbox text1
    Thanks

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    0.9 is the Numerical representation of 90%, i.e. the way it must appear to be used in mathematical computations.

    If you want to enter 90 and have it mean 90%, you'll need to

    1. Define the Field, in the underlying Table, as a Text Datatype
    2. Leave the Format Property blank
    3. Use the code, below, to add the Per Cent sign


    Code:
    Private Sub PerCent_Field_AfterUpdate()
     Me.PerCent_Field = Me.PerCent_Field & "%"
    End Sub


    If you later need to use the field for math, you'll have to convert it back to a number, using something like this:

    Left(Me.PC_Field, InStr(Me.PC_Field, "%") - 1) / 100

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You can have it as a number in the tables but you must divide it by 100:
    Format(12.34/100,"##.00%") = "12.34%"

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

Similar Threads

  1. Replies: 1
    Last Post: 09-17-2014, 04:40 PM
  2. Replies: 3
    Last Post: 12-21-2012, 02:27 PM
  3. Replies: 3
    Last Post: 01-27-2012, 12:59 AM
  4. Percent textbox unusual behaviour
    By Deutz in forum Forms
    Replies: 4
    Last Post: 06-05-2011, 06:46 PM
  5. Access 2007: Percent Format Issue
    By diane802 in forum Access
    Replies: 6
    Last Post: 12-30-2009, 10:29 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