Modules & VBA :: Cannot Seem To Get Percentages In Query
Aug 10, 2015
I am using following function to return percentage spend by testing against number of months elapsed. I am unable to show the CSpend as percentages and I cannot seem to get the percentages in the query.
Public Function CSpend(mMonths)
If (mMonths) = -4 Then
CSpend = 1
ElseIf (mMonths) = -3 Then
CSpend = 0.99956
ElseIf (mMonths) = -2 Then
Hey guys. I have a boolean expression which I want to calculate the percentage of. I have the field 'Regular Booking' which is either true or false. I have 6 true and 5 false, equalling to 11 in total. I've tried using: 100*[CountOfRegular Booking] / [TotalRegular Booking] but this gives me the same percentage for both true and false. So if I enter 5 I get 45.54% for both true and false... why is this? I've had trouble with this for ages now and I'm pulling my hair out, lol. :( Thanks guys!
Just started doing access at work and have a problem.
I have a database. Each record has a bunch of different fields.
In one field, the record can either be DC or DS (different classifications).
I would like to run a query which would tell me the percentage of DCs and DSs.
I have managed to create a query that counts the total of each one, but for the life of me i cannot figure out how to do the percentages.
Can anyone help?
I am using Access 2000 and my query is being made in design view
The Query has 2 columns:
Column 1 Field: DC/DS Table: Main Total: Group By Show: yes
Column 2 Field: DC/DS Table: Main Total: Count Show: Yes
Can I add the percentage section as another column (using an expression?) or will it have to be another query, that runs the above query then uses data from that?
Simple question: how do you convert vlaues into percentages? I have a boolean expression so when it's ticked the bookings are regular, and if they're false they are occasional bookings. I have used 10 bookings as test data (5 regular - true, 5 occasional - false). How would I convert these into percentages? For example, I've used the "Count" total to fint the number of regular and occasional booknigs, which are both 5. This is 50%, but how would I do that? Thanks for your help guys. :)
ok, so i have to work out week by week percentage uses i have a query that already finds the bookings in the week already, that works fine, but then i need to find the % use for that week, which is the count of the number of bookings in the week / 21 ive tried doing this in an update query, but it doesnt like me :) any help would be great :) i have a % use field in my table that it updates to, but im flexible :) thanks
I have a requirement to give a % figure from 2 time fields. I would have thought this was simple, but when I divide the fields I keep getting #Error. Its not an error caused by a divide by zero, i can recify those. Can anyone point me in the right direction to get a % from 2 time fields.
This is probably simple but it's something I haven't had to do before.
I have a main table. I have a filter query based on this table. I have a report, based on the query, which displays the total number of records in the query. In the same report, I would like to display this total as a number (already done, obviously) and also as a percentage of the total number of records in the main table.
Been searching for an answer to this one but still cant quite get it.
I am using an option group to subtract and add percentages on an amount in a text box. This is the code i am using but there is something wrong. My syntax is out.
Is there a data type that I can use that will handle both text and numbers such as percentages? Or is there a way I can set the field type to text then convert the text to a percentage? I plan on using this field in a form so when the user inputs the info I will want to display it in the correct format. Any ideas or suggestions?
I'm setting up a database for student evaluations. Students have several options as to how well the instructor did for each survey question. I've been able to set up the data entry form to my liking, and I can use a query to average the total answers to each question, including a count of how many people responded. HOWEVER, I need to calculate the percentage of responses for each option. For example, I need to know the percentage of students who picked "Excellent" for question 1, how many students chose "Very Good", how many chose "Good", etc., so on and so on for every question. How can I do that? I'm completely stuck and a novice user. HELP!!:eek:
can anyone explain how to use a percentage in a table.
i have a field designated as data type "number" and format set to Percentage.
when i go to datasheet view and attempt to enter in these percentage (1%,50%, 34%, etc) it is multiplying the data entered by 100 (100.00%,5000.00%,3400.00%, etc).
I'm trying to create a table in an Access Form or create a block of code to export the table with query results to Excel or PDF. In the end I would like to run a query or queries to populate the table or export the query results creating the table. I'm not sure the best way to create the table.
I'm creating a report that list multiple users providing an input of "approved" or "not approved" for a plurality of proposals. I'm trying to create a report that lists the percentage for each user that calculates the number of times the user inputs "not approved" over the total number of proposals that particular user reviewed.
For example,
Steve reviews 50 proposals, and of the 50 proposals Steve inputs 10 of those proposals to be "not approved". I need a calculated field that counts the number of times that Steve inputs "not approved" and calculates that 20% of proposals reviewed are not approved, of all the proposals he reviewed. The number of proposals are continuously being added so the number 50 will not always be the denominator.
There are at least 10 other users that I have to do the same calculation but if I'm able to do the example above.
We have a model at my job which shows every job code one can do (there are only about 25 of these jobs) For example, let's say one job is called "Trade Settlements" and it's been estimated that we spend about 1000 minutes a day doing this particular job across the entire floor.
Well, I want to come up with a way to allocate the minutes of this to certain hour blocks and determining whether our group is over/understaff given the results.
So let's say I want, 30% of it to be done from 9-10 am, 10% done over the next 4 hour time blocks, and 2-3 pm for the remaining 30%.
Thus, we'd get something something like 300, 100, 100, 100, 100, 300 minutes and 0's for other time blocks.
These percentages would be input fields so if anyone types in a percentage, they get # of minutes spent for that hour on that job. Ultimately we would add these numbers up with other jobs and be able to easily update from there for any job type we wanted.
I created a database to record time logged per workorder for each employee on my job. Each time log has a specific "Trade" attached to it along with a number of hours the employee spent on that workorder. I've created a report to display how much time the selected employee spent on each workorder (within a date range) and now I want to see what percentage of their time was spent on a particular "Trade" (for instance, during September Employee "name" spent "percentage" of their time on Electric, "percentage" on HVAC, "percentage" on Plumbing...[and so on])
I have trades listed in the table and in the time log, the form writes to the trades area of the table (probably very elementary for this discussion) and the report lists the name and grand totals with percentage of total time on each workorder, but does not list any trade information.
How can I add this into my report, preferably at the end (Report Footer?)
I have a database that I'm building off of a process that is currently done in excel. I want my percentages calculations to match what I get in excel but I'm finding the numbers to be off by as much as .4%. I'm pretty sure they issue has to do with the precision of its calculations but what the best settings are.
My percent numbers are currently set to the field size "Double" with a percent formatting. My currency numbers are set to the format Currency and decimal places on auto.
I am currently using Access 2007 and have created a huge database for our investment managers to calculate the income based on percentages. The percentages are created in Excel. I have uploaded into the database both the June and the July percentages. When I run the query for my report using the date range for June, it works fine. When I request just the July information (entering the date range for July) the June data is doubled on the report.
All I'm trying to do is a make table (table name to overwrite: "TBL_5_7_RFCs") query via VBA so I can loop through a set of VARs in a table. Here is my code:
Code:
Public Function test_sql() Dim Conn As ADODB.Connection Dim RS As New ADODB.Recordset Dim MySQL As String Set Conn = CurrentProject.Connection RS.ActiveConnection = Conn
[code]...
I'll add the loop and array once I get this working but I'm stuck.
I am looking for the vba to have a query cycle through using records from another query as the parameter run and export for each of the records on the second query.
Table 1 has information with all clients query 1 has x, y, z being pulled > client used as parameter query 2 has the list of clients
Currently I have the coding to run the query and export however I am not sure how to get it to repeat for each client.
Code: Private Sub CmdInternalReports_Click() Dim xlApp As Excel.Application Dim rstDetails As DAO.Recordset Dim strTab As String Dim strDir As String Set xlApp = Nothing Set rstDetails = Nothing
[code]...
There can be upto 70 different clients or as little as 2 depending on the day. So the Query I have takes a list of the clients that receive the report and runs it against the imported table to only give the ones with data day.
PHP Code:
tblClientReport.Distro
Is where I have the report via client name linked the the distro list that should be pulled.
I have created something from our transport department and need to set up so he can select a command button and email from a query, but where would I put the query details in the coding below
VBA used
Dim strSQL Dim db As DAO.Database Dim MailList As DAO.Recordset Dim objOutlook As Outlook.Application Dim objemail As Outlook.MailItem Dim Subjectline As String Dim BodyFile As String
I am trying to create SQL within a sub that uses the sum of three elements in a table and the current date but I then want the name of the table that these entries relate to to be inserted into the table also so the Totals for a table called C5_1 would show in the table as:
BWS Date BASIC BONUS COMMISSION C5_1 18/12/2014 2000 500 700
But there could be multiple tables and I am using a recordset to give me the lsit of tables. I just cant seem to get the SQL of the SELECT for the tablename to work.
Below is what I am currently using:
Code: Dim db As Database Dim rs As Recordset Dim strSQLText As String Set db = CurrentDb() Set rs = db.OpenRecordset("tblofC5_1Tables", dbOpenDynaset) DoCmd.SetWarnings False
[code].....
There is currently only one TableName in the Table and that is C5_1
Ive got an SQL query as below, what Im trying to do is get the total value of that SQL query and drop it into a form text box.
The placing of the result on the form textbox isn't a problem but getting a sum total of the query result is proving to be a little tricky tricky tricky.
Code: Dim strSQL As String strSQL = "SELECT TestTable.Hours FROM TestTable" & _ " WHERE (((TestTable.sUser)=Forms!Submittedsheet_frm!AdminSelect_Combo.Column(0) AND" & _ "((TestTable.[Task Date])>=[Forms]![Submittedsheet_frm]![FromDateAdmin_TXTBox] And" & _ "(TestTable.[Task Date])<=[Forms]![Submittedsheet_frm]![ToDateAdmin_TXTBox];"
Instead of the queries I want to do this in vba with a recordset
Code: ' Select from first query sql = "SELECT tblOriginal.ROUTE, Count(tblOriginal.ROUTE) AS CountOfROUTE " & _ "FROM tblOriginal " & _ "GROUP BY tblOriginal.ROUTE " & _ "ORDER BY Count(tblOriginal.ROUTE) DESC" ' Select max from result of first query sql2 = "SELECT Max(qryRouteCount.CountOfROUTE) AS MaxOfCountOfROUTE " & _ "FROM qryRouteCount;"
The slq works fine for the first Query, I could then do a iMax = rs("CountOfROUTE") to get the max value as they are ordered.
but how can I write sql 2 so that it selects the Max from the Query 1 select statement.
I have a form in which am gathering information from the user to populate a table(Customer Master List) and at the same time (btn_Copy_Click Event)transferring the info to another form(Case) populating another table(Customer_Call). It is working fairly well, My issue is that before transferring the info I need to run a check(SQL Query) to make sure the customer or actually the Well ID don't exist in the Customer_Call table. I am trying to do this in pieces .....
1) capturing the well_Id in a variable(WellID) in the first form and using that to build the sql string and query the Customer_Call table.
2)once that works place it in a if / else clause to copy or not with appropriate messages
With that I am stuck in step 1
It works up until Set rst = CurrentDb.OpenRecordset(strSQL) the i get Run-time error '3061' Too few parameters. Expected 1.
Code: Dim WellID As String Dim strModel As String Dim strSQL As String Dim rst As DAO.Recordset WellID = Forms!f_Customer_Lookup.Well_ID MsgBox WellID ' testing to see if it picks up the correct box in form strSQL = "SELECT Customer_Call.[Cus_Well_ID] " & _ "FROM Customer_Call " & _ "WHERE Customer_Call.[Cus_Well_ID] = WellID;" Set rst = CurrentDb.OpenRecordset(strSQL) strModel = rst!Cus_Well_ID rst.Close MsgBox rst ' Testing to see if the strSQL captured the data Set rst = Nothing End Sub
Code: TRANSFORM nz(count(T_qa.qaQAPK),0) AS SumOfQAs SELECT month(qaDate) AS QAmonth, Count(T_qa.qaQAPK) AS QAs FROM Q_ALL_qa GROUP BY Month(qaDate) PIVOT month([qaDate]) IN (1,2,3,4,5,6,7,8,9,10,11,12);
This query is record source for a report, then this report show all calculations in a form.
I have 7 of each (query + report) all showing on the same form.
All those queries calculate data for all departments.
In the form, I have placed a combobox.
What I want is to create a vba code which will add clause WHERE to all queries at the same time and then run it.
Code: WHERE qaDeptFK=Forms!F_CompLvl.cboDeptStats
However, if nothing has been selected in the combo, I want the queries to calculate data as normal, for all departments.
Where do I place the vba statement? Is it under combobox AfterUpdate event?
I am planning to use this: (As I never done it before) [URL] .... Modifying SQL On-The-Fly section