Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2015
    Posts
    2

    Question Unanswered: 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
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    28 / 26 is 1.076923
    Multiplied by 100 is 107.6923
    If you set the format of the control to percent it will multiply the value by 100 to wgat you are seeing.
    So the fix is
    1 correct the equation to
    Code:
    textbox3 = (txtCARCov2 / txtCARCov1) *100
    2 then remove the format on the control OR omit the * 100 from above
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2015
    Posts
    2
    Quote Originally Posted by healdem View Post
    28 / 26 is 1.076923
    Multiplied by 100 is 107.6923
    If you set the format of the control to percent it will multiply the value by 100 to wgat you are seeing.
    So the fix is
    1 correct the equation to
    Code:
    textbox3 = (txtCARCov2 / txtCARCov1) *100
    2 then remove the format on the control OR omit the * 100 from above
    Thank you for answering man, really appreciate it. I kinda figure it out thanks to Google.
    I found out that I was doing it the wrong way.

    This is the code that Im using.

    Code:
    =FormatPercent(Round(([txtbox2]/[txtbox1]),2))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •