472,782 Members | 1,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

How To Calculate percentages in Access???

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
9 27638
missinglinq
3,532 Expert 2GB
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
AZKing
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
8,834 Expert 8TB
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
AZKing
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
32,534 Expert Mod 16PB
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
AZKing
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
32,534 Expert Mod 16PB
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
AZKing
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
32,534 Expert Mod 16PB
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

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

Similar topics

0
by: michael | last post by:
I've got a 3-column layout using percentages to define width of each div-column. #left-col { width: 20%; background-color: green; float:left; } #center-col { width: 60%; background-color: blue;...
7
by: richard | last post by:
I have a table with 5 fields into which the user will enter numbers, which must add up to 100%. Say the fields are Toyotas, Missans, Mazdas, Hondas and Other. I am having trouble writing a query...
26
by: Mike Barnard | last post by:
Hi all. I am playing with html and css. I don't (yet) have a working site, I'm just trying to build a working, basic template I can use for a couple of ideas I have. I recall reading a...
7
by: Jurek | last post by:
I have 10+ experience in C/C++ - mostly automation and graphics. I have never written any business apps though. Recently I've been asked to write a simple report that would calculate sales...
39
by: Umesh | last post by:
Plese help. Is there any software by which we can do that?
1
by: Dineo | last post by:
Hi there I've created a database and a pivot table but I need to calculates percentages of all the WithdrwalAmt (the amount being withdrawn when retire) per PayeeName (where the money was invested...
3
by: Libber39 | last post by:
Hi everyone, Have a query on how to calculate the amount of weeks and days contained in a number in an access query. ie: the difference in days between 2 dates amounts to 17 days. I want to now...
3
by: martin DH | last post by:
Access 2003 I have a table (TASKS) filled with data from an external source. The table lists several tasks for employees to complete and has a text field (STATUS) that identifies where in the...
7
by: buddyr | last post by:
Hello, can I write a query that will give percentages of records in one field? table example: table1 IdNumber model condition 01 045 good 01 045 ...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.