By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

How To Calculate percentages in Access???

P: 12
Hi all,

I would like to know how do you go about calculating percentages in Access.

For example, in a form I have 3 combo boxes with drop down menus where a user can select "Yes" or "No" and a text box where I will calculate a percentage. What I am looking for is something like this:
If combo1 = "yes" then percentagebox = 1 / 3 * 100
ElseIf combo1 AND combo2 = "Yes" then percentagebox = 2 / 3 * 100
ElseIf combo1 AND combo2 AND combo3 = "Yes" then percentagebox = 3 / 3 * 100.

Can anyone tell me how can I go about creating and calculating percentages such as this in Access? I appreciate any help.

Thanks
Jan 26 '07 #1
Share this Question
Share on Google+
9 Replies


missinglinq
Expert 2.5K+
P: 3,532
I think you need to tell us a little bit more about exactly what you're trying to accomplish, AZKing. I have to tell you, what you've posted so far sounds as if you're trying to swat a fly with an atom bomb!
Jan 26 '07 #2

P: 12
Ok, I am trying to do the following:

In a form in Access, I have 3 drop down menus where you can select "yes" or "no". I also have a text box where I would like a percentage to show up based on the answers of the 3 drop down menus. For example, if in drop down menu 1 "yes" is selected, I would like 33.3 % to show up in the text box. If in drop down menus 1 and 2 "yes" is selected, I would like 66.7 % to show up in the text box. If in drop down menu 1, 2, and 3 "yes" is selected, I would like 100 % to show up in the text box.

Is this a little more clear?

I would appreciate any help. Thanks.
Jan 26 '07 #3

ADezii
Expert 5K+
P: 8,692
Hi all,

I would like to know how do you go about calculating percentages in Access.

For example, in a form I have 3 combo boxes with drop down menus where a user can select "Yes" or "No" and a text box where I will calculate a percentage. What I am looking for is something like this:
If combo1 = "yes" then percentagebox = 1 / 3 * 100
ElseIf combo1 AND combo2 = "Yes" then percentagebox = 2 / 3 * 100
ElseIf combo1 AND combo2 AND combo3 = "Yes" then percentagebox = 3 / 3 * 100.

Can anyone tell me how can I go about creating and calculating percentages such as this in Access? I appreciate any help.

Thanks
I think what you are looking for is the Format() Function in which an Expression can be properly formatted to produce a Percentage as in:
Expand|Select|Wrap|Line Numbers
  1. Format$(1/4,"Percent") ==> 25.00%
Jan 26 '07 #4

P: 12
I think what you are looking for is the Format() Function in which an Expression can be properly formatted to produce a Percentage as in:
Expand|Select|Wrap|Line Numbers
  1. Format$(1/4,"Percent") ==> 25.00%

Hi, I'm not sure I understand, can you please give me an example?

Thanks.
Jan 26 '07 #5

NeoPa
Expert Mod 15k+
P: 31,754
What happens if Combo2 is selected on its own?
Your question is not very clear in this respect. What is the idea behind this? That may help to understand where you're coming from.
What do you have on your form at the moment? :confused:
Jan 27 '07 #6

P: 12
What happens if Combo2 is selected on its own?
Your question is not very clear in this respect. What is the idea behind this? That may help to understand where you're coming from.
What do you have on your form at the moment? :confused:
Well, I'm gonna freeze or make not visible combo2 and combo3 if combo1 is not selected, same with combo3, I will freeze it or make it not visible if both combo1 and combo2 are not selected, which will remove the possibility of this occuring.
The idea behind this is to calculate the percentage of work completed. So if combo1 is selected as completed, than the percentage should be 33.3 %; if combo1 and combo2 are selected as completed, than the percentage should be 66.7 %; and if combo1, combo2, and combo3 are selected as completed, than the percentage should read 100 %. I hope this is a little more clear.

Any suggestions?
Jan 27 '07 #7

NeoPa
Expert Mod 15k+
P: 31,754
This code will show the percentage required but as text.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_AfterUpdate()
  2.     Call TextSource
  3. End Sub
  4.  
  5. Private Sub Combo2_AfterUpdate()
  6.     Call TextSource
  7. End Sub
  8.  
  9. Private Sub Combo3_AfterUpdate()
  10.     Call TextSource
  11. End Sub
  12.  
  13. Private Sub TextSource()
  14.     If Me!Combo3 = "Completed" Then
  15.         Me!percentagebox = "100.0%"
  16.     Elseif Me!Combo2 = "Completed" Then
  17.         Me!percentagebox = " 66.7%"
  18.     Elseif Me!Combo1 = "Completed" Then
  19.         Me!percentagebox = " 33.3%"
  20.     Else
  21.         Me!percentagebox = "  0.0%"
  22.     End If
  23. End Sub
If you already have code (I suspect you do) in the AfterUpdate event procedures of your ComboBoxes then just incorporate this call into it.
Jan 27 '07 #8

P: 12
This code will show the percentage required but as text.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_AfterUpdate()
  2.     Call TextSource
  3. End Sub
  4.  
  5. Private Sub Combo2_AfterUpdate()
  6.     Call TextSource
  7. End Sub
  8.  
  9. Private Sub Combo3_AfterUpdate()
  10.     Call TextSource
  11. End Sub
  12.  
  13. Private Sub TextSource()
  14.     If Me!Combo3 = "Completed" Then
  15.         Me!percentagebox = "100.0%"
  16.     Elseif Me!Combo2 = "Completed" Then
  17.         Me!percentagebox = " 66.7%"
  18.     Elseif Me!Combo1 = "Completed" Then
  19.         Me!percentagebox = " 33.3%"
  20.     Else
  21.         Me!percentagebox = "  0.0%"
  22.     End If
  23. End Sub
If you already have code (I suspect you do) in the AfterUpdate event procedures of your ComboBoxes then just incorporate this call into it.
Thank you very much, it worked great!!! I was very close myself, I just couldn't get it to work properly. I appreciate your help and input and thanks again :)
Jan 27 '07 #9

NeoPa
Expert Mod 15k+
P: 31,754
Glad I could help.
Hopefully you see the concept and that's now something you'll be able to do in future :)
Jan 27 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.