Queries :: Counting Values And Creating A Table For Each Defined Count
Apr 14, 2014
I am using an existing database which allows my company to track claims information. One report my supervisor has asked for is a table which shows the counts of each kind of event occurring at a district level by department. For example, the classifications are injury classes like FSA, so I need to design a report which says facility a has 3 fsa's in the Wireline department in a table format. I have been looking into union queries as suggested by other sites but nothing seems to work. My labels are District, Analysis Code and Department.
I have a question regarding counting of text values base on their status and using that result to a calculation.
Say, I have a table of Demand of Positions, wherein, I have a specific Job Title for a certain Department that have number of workers needed (demand quantity) and a table of candidates for that job title and their status, say, Arrived, Visa Processing, Visa Applied, Visa Issued, and With Ticket.
What I would want is to make a summary out of the two tables, where the query will count how many candidates are there in that specific job title and have a field of status say, field of Count of Arrived, Count of Visa Processing and etc., and a field where I can add all of the count of candidates per status and deduct the result to the demand quantity where that field would be named Balance.
The problem is that the status varies on every candidate on that specific job title because the status field is used to track the progress of each candidate and this scenario will make the query blank because there would be no such record due to their status.
I tried making a summary following my requirement and you will see that in the attached file together with the SQL code of that query that the balance field value is blank.
Client has asked me to create a report showing summary of monthly sales by day. That was easy. I created a query for the month the user selected and then summarized and group the data by day. Client like the result but would like to see zeros on the report for non sales days. Non sales days are days like holidays and there are no sales.
I am thinking of creating an table with 31 days of zero values and then join the two tables in a query? Or, should I create a temporary table with code and then merge the two tables which the existing query which I can then use for the report?
I have a table that has two columns "Nationality" and "Gender". I wanted to run a query that will Group the nationality and then split the gender column into two columns and after that it will count both gender columns for each nationality. When I posted this question in "Reports" section I got the suggestion to use the SELECT COUNT in SQL. It worked but only for nationality. I couldn't get it work for the Gender column. I searched alot and the only thing I got was the SQL function to split data from one column into two but that also didn't serve the purpose (check the link to see why: [URL]) At last, I went on to create a cross tab query. Selected Nationality as Row header, Gender as Column header and Customer ID as calculation point. And there I got the result I needed. The SQL Code looks like this:
Code: TRANSFORM Count(Register.[Customer ID]) AS [CountOfCustomer ID] SELECT Register.National, Count(Register.[Customer ID]) AS [Total Of Customer ID] FROM Register GROUP BY Register.National PIVOT Register.P_Gender;
I'm having trouble creating a query to give me a count of all the males with a certain ethnicity and females with a certain ethnicity. I have a table that is setup for those two categories. It has the ethnicity and gender listed with check boxes (requested by the user) and when ever I run the query with the count total, for example : Caucasian Males, it returns all Caucasians whether male or female. I've tried a few different ways to get this done, but with no success.
Based on one particular report style, have multi select criteria to produce user selected criteria
based on selections from a. Interest, b. State, c. Type
Report 1. sorts on Interest, 2. sorts by State, 3. sorts by Type ... and each report includes selections of the other 3 selections plus basic data common to all.
Plus, the Interests have a table where the main interest data is stored in a ContactInterest table, while the specific interest selections, per contact, are stored in the Contact table as Interest_1 through Interest_20.
In the Report, when it is sorted by Interest, while I have a concantated output for 5 of the selections, they also, want to sort alphabetically by the interest selections (which changes per Contact).
There is already a form for printing reports that are more static, and I wanted to add these selections on that form, perhaps as a subform, to allow printing of the reports, mentioned, and associated mail labels to the targeted addresses per group.
Any help, direction, guidance, or redirection would really help and is MUCH appreciated. I've tried many options, and as a newbie, have not yet found a solutions- or solutions.
Thank you so much. (time is of the essence and my skills are small so far.)
I am using Access 2010 on a Windows 7 laptop. I need a query to provide a list of ID's that have more than one occurrence of IDandDate combined but haven't been successful getting past syntax errors.
Using this table structure as an example: ID - defined as text field Date - defined as date/time field TestValue
This legacy table contains a record for each test. The table should be unique based on the ID and Date combination but was never restricted to that rule. I am converting to a new table but need to identify the duplicate entries so they can be addressed by business folks.
I am currently using the below code to query values that have a unique "OverrideDescription" and where by the "Upload Date" is always the latest.
SELECT t1.* FROM [DaisyServiceRates-Amended] AS t1 LEFT JOIN [DaisyServiceRates-Amended] AS t2 ON (t1.OverrideDescription = t2.OverrideDescription) AND (t1.[Upload Date] < t2.[Upload Date]) WHERE t2.OverrideDescription IS NULL;
However I also need to be able to do a unique count of the [OverrideDescription] field.
I have found methods whereby I can do use, but they all use a GROUP BY function, the issue being that when I use this method it prevents be from updating the values saying "recordset not updateable".
Any method that does not use the GROUP function. I did also try preforming the COUNT on a separate table and doing as JOIN, but this also prevented updates to the date.
Report has records of errors. There are 3 types of error. In the report footer, I would like a total count (this is working!) and a count by type (can't get this to work).
Error Total =Count[ErrorType] Compliance Total =Sum(IIf([ErrorType]="Compliance",1,0)) Audit Total =Sum(IIf([ErrorType]="Audit",1,0)) Quality Total =Sum(IIf([ErrorType]="Quality",1,0))
I have tried setting groupings on the report but this alters the detail sorting (currently sent by the date field newest to oldest) and provides the count within the detail.
How do I count the number of records with values within specified ranges?
My database contains a field with values ranging from say 1 to 1000. I need to write a query to show count the number of records with values in ranges I specify in the query.
I'm looking for output such as
<100 - 50 records 101 - 500 - 30 records 501 -1000 - 50 records
I have built an Access DB containing 3 tables: dimensions, time, companies. The tables are not linked and are to be used to look up values for the new form. The goal is to create an Access form that would allow the user to select distinct values from all 3 tables, enter some own data and then execute an append query to add the record to the main table.
Something like this:
Initially I have 3 tables:
Prepopulated Dimensions table with fields: dimension ....
Prepopulated Time table with fields: Date Day Month Year
Prepopulated Companies table with fields: Company ....
My form is to be able to select distinct values (combobox) from all three fields: Company Dimension Day Month Year Value (data entered by user)
The record then is appended to the Main table containing: Company Dimension Day Month Year Value (data entered by user)
I have a table that deals with current data (as in member rentals of items). The normalized tables that we have been given include a rental history table. The idea is that, when the member has returned the product a history entry is made in the completed rental table.
I wish to have a button which is clicked to triggers this event. Would I program a macro to do this? In other words, would I create an event that passes those values to the relevant fields in the other table (Name, date issued, return date etc)?
I am facing the difficulty to solve the calculation of my Employees payment table in query, employees having three type of payments 1. Leave 2. Air ticket 3. EOSB so I have created three different queries named Airticket_Accruals, Leave_Accruals, EOSB_Accruals for these tables.
The problem is I need to include how many payments have been done to every employee in total to my every individual query (airticket,leave & EOSB) than I will less the accrual that will give me the balance I need to pay them.Field for Payment table is as follows and it has relation with Employees table with Emp_ID field.
I'm using Access 2010. I need to calculate a score based on values selected in a table by looking up corresponding values in other tables. I have a "Project" form to create new entries into the Project table (see Table 1). When I create a new project record, I will select values for the Payback and Need fields by selecting options from a list. The Payback list is pointed at Table 2 and the Need list is pointed at Table 3. In the below example, I created the "ABC" project and selected "1 year" for the Payback field and "Repair" for the Need field. Pretty simple.
Now that I have the "ABC" project loaded to my Project table, I'd like to create a report that will show a "score" for this project. The score should be calculated as follows: Payback Impact + Need Impact. In this example, the score should be 30 (Payback Impact of 20 + Need Impact of 10).
I have a query with an INNER JOIN and ORDER BY that is working great. Now, using the same JOIN, I need to update values in one table with the values in another. I thought it would be simple until I learned you can't do an ORDER BY with an UPDATE. Is there another way to achieve the same result? If you remove the 'ORDER BY', the statement below doesn't produce an error but the results are not correct:
UPDATE TableA INNER JOIN TableB ON (Left(TableA.CDN,6))=(TableB.CDN) SET TableA.HCC = TableB.HCC WHERE TableB.HCC Like '241*' AND TableB.BBB = 'X' AND TableA.CCC = "1234" AND TableA.HCC IS NOT NULL ORDER BY TableB.HCC, TableA.CDN;
I copied some VBA from one database to another. I didn't change anything and I am able to run it fine in the first database. But in the DB I pasted it to, I am received a Compile Error message with the XlApp As Excel.Application area highlighted.
Function OpenAutoCount() Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook
This is giving me the error 'User defined type not defined'. I know I have to set something in a list somewhere but have forgotten how to do that. Where to go, and what to set?
I have a query it correctly displays output as i require. i want to update/store the output query to a table named ustate. my query is as under
Code: SELECT Auth.nit, UC+UL+UC AS Aut, (select count(NO) from Pers where nit=Auth.nit and rOrd>4) AS Present, (SELECT COUNT(no) FROM pers WHERE nitFrom = auth.nit) AS DIn, (SELECT COUNT(no) FROM pers WHERE nitTo = auth.nit) AS DOut, Present-Dout+Din AS Held FROM Auth WHERE (((Auth.Type)='tata')) ORDER BY Auth.nit;
On Compiling my assecc database VB code I get the following error message "User defined type not defined". I understand it is beecause I have not declared the Variable Type, but have no idea to exactly which part of the code the error is referring to.
How do I find out WHICH User defined type is not defined, especially when I have not got any (or do not want to use any) user defined types?
Thank you in advanced programming wizards. Kind regards, Adam.
Hello, I have the following code and i don`t know what's wrong Private Sub cmdCautare_Click() Dim strSQL As String, strOrder As String, strWhere As String 'Dim dbNm As Database 'Dim qryDef As QueryDef 'Set dbNm = CurrentDb() strSQL = "SELECT DOSARE.DosarID,DOSARE.DenumireDosar,DOSARE.CodDosa r,DOSARE.DataDosar,DOSARE.Denumire,DOSARE.Data,DOS ARE.Stadiu FROM DOSARE" strWhere = "WHERE" strOrder = "ORDER BY DOSARE.DosarID " If Not IsNull(Me.txtDenumire) Then strWhere = strWhere & "(DOSARE.DenumireDosar) Like '*" & Me.txtDenumire & "*' AND" ' " End If If Not IsNull(Me.cmbStadiu) Then strWhere = strWhere & " (DOSARE.Stadiu) Like '*" & Me.cmbStadiu & "*'" End If DoCmd.Close acForm, "frmPrincipal" DoCmd.OpenForm "frmRezultateCautare", acNormal Forms!frmRezultateCautare.RowSource = strSQL & " " & strWhere & "" & strOrder End Sub Here: Forms!frmRezultateCautare.RowSource = strSQL & " " & strWhere & "" & strOrder The error is the following "Application-defined or object-defined error"
Hey, I'm new to microsoft access, and I could do with a little help please :) . On a database I have created, I have a table with the field "Results" in it. This field has been set up in the Lookup properties to be a choice from "Win" "Loss" or "Draw". My question is, what is the expression I would use to count the total number of records in my form with "Win" selected?
I tried to set up the DCount expression, but this gave me some odd results.
Currently my database is set up like this,
TBL_Match_Results: Fields:
GameNumber (Autonumber + Primary key) Date Result (With the choices above)
Then I made a continuous form from this table, and on the Form Footer I had a text box with the value,
I had hoped this would simply give me the total number of records with a win in them. However, insted the value changes depending on which record I have selected on the form. It is "10" if the selected record is a win, or "0" if it is not. I'm not sure if the problem is the poorly written expression (I'm not 100% sure how to work them), or if I'm even using the right expression (I was only told to use DCount). If anyone could shed some light on this, I would greatly appreciate it!
EDIT: I've just realised where the 10 is coming from, it's the number of records in my table, when i added a new one it changed to 11.