Results 1 to 6 of 6
  1. #1
    pipoconanan45's Avatar
    pipoconanan45 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    5

    Question Calculating Percent in Report

    Good day everyone, I'm complete novice when it comes to VBA and Database so please bear with me and Ill do my best to explain what my problem is.

    Im trying to make a report where their are three textboxes (textbox1, textbox2, textbox3). What Im trying to do is calculate the percentage of the two values that are in textbox1 and textbox2 and result would be shown in textbox3.

    These are the codes in the Control Source in both textbox.

    Code:
    Textbox1 - =Sum(IIf([FldID]="1",[BrgyCovered],0))
    Textbox2 - =Sum(IIf([FldID]="1",[SubProjImp],0))

    Both values from textbox1 and 2 came from a query.


    I tried using this codes in the Control Source but they dont work.

    Code:
    Textbox3 - =([txtCARCov1]/[txtCARCov2])*100

    for example textbox1=28 and textbox2=26 the answer should be textbox3=93%


    The answer came out as 10769.23% instead of 93%

    Thank you in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Well, 28/26 is 1.0769, which is 107%, so times 100 would be 10769%. If you're formatting as % you don't want to multiply times 100.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pipoconanan45's Avatar
    pipoconanan45 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    5
    im sorry i got it the wrong way it should have been 26/28*100 the answer then is 9285.71% is there a way to round this off to make it to 93%?

    =([txtbox2]/[txtbox1])*100

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Well, don't multiply by 100 for starters. You can wrap the formula in the Round() function if you want.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pipoconanan45's Avatar
    pipoconanan45 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    5
    Thank you man. I got it, I didnt know that Ive been doing it the wrong way.

    Code:
    =FormatPercent(Round(([txtbox2]/[txtbox1]),2))
    Im using this code now.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Calculating Percent of a Test Score
    By cohnhead in forum Queries
    Replies: 5
    Last Post: 11-21-2014, 03:22 PM
  2. Replies: 1
    Last Post: 09-14-2014, 02:54 PM
  3. Replies: 5
    Last Post: 12-08-2012, 10:10 PM
  4. Negative percent on a report
    By bcoots in forum Reports
    Replies: 2
    Last Post: 01-05-2012, 03:05 PM
  5. Calculating a sum on a report
    By missourijc in forum Reports
    Replies: 0
    Last Post: 10-30-2008, 07:21 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