Modules & VBA :: Counting With SQL

Dec 19, 2014

I built a query "WplatyKlienci" which sum all of payments "Sumawplat" from my clients "klient".

Code:

SELECT SUM(tblWycenaZakonczone.cenanetto) AS Sumawplat, tblKlienci.nazwaSkrocona AS klient
FROM tblWycenaZakonczone INNER JOIN (tblZleceniaZakonczone INNER JOIN TblKlienci ON tblZleceniaZakonczone.id_k = tblKlienci.id_k) ON tblWycenaZakonczone.id_zlecenia = tblZleceniaZakonczone.id_zlecenia
WHERE tblWycenaZakonczone.cenanetto is not null
GROUP BY tblKlienci.nazwaskrocona;

Now I need to know 2 things and I have problem with counting in sql:/

1) what percentage of the total amount represents a particular client.
2) I want to create a graph, so I need to do another query, which shows values form no. 1 only for 10 clients with the largest payments + one position named "others" which represents rest of clients

View Replies


ADVERTISEMENT

Modules & VBA :: Counting Input In A Subform?

Sep 11, 2013

i have a field in the form where you can choose how many vehicles you have in the contract.

the field is called

amount_vehicle

Then i have a subform where you put the vehicle in.

So there is a 1 to n relation between the form and the subform

The id of the vehicle is called ID vehicle

I want that e.g a user chooses 2 vehicles in the form. Now it is not possible to put in 3 vehicle in the subform.

I�ve created the following code, but it doesnt work.

[CODE]
If DCount("*", "subform", "ID vehicle = " & Me.Parent!ID vehicle) >= Nz(Me.Parent!amount_vehicle, 0) Then
MsgBox "no vehicle"
Cancel = True
Me.Undo
End If]

View 4 Replies View Related

Modules & VBA :: Counting Value And Assigning Numerical Value?

Aug 15, 2013

I am working on an app, that has a field named "Name". I have everything set up with a module, which, for example, the name "John", it assigns 1. when it sees "John" again it assigns 2. Then "Jane" It assigns 1 again. I want the module to see every instance of "John" to assign the same number, 1, then all instances of "Jane" 2, etc. Here is the code in the module I am using, but it is assigning the values wrong. My final plan is to use the numbers for conditional formatting, so all johns one color, all janes, a different color. I can't use the conditional formatting wizard because these names pop up at random, and the names populate at random.

Option Compare Database

Global GBL_Category As String
Global GBL_Icount As Long
Public Function Increment(ivalue As String) As Long
If Nz(GBL_Category, "zzzzzzzz") = ivalue Then
GBL_Icount = GBL_Icount + 1
' MsgBox icount
Else
GBL_Category = ivalue
GBL_Icount = 1
End If
Increment = GBL_Icount
End Function

View 1 Replies View Related

Modules & VBA :: DCount Function Counting 0s As 1s

Sep 24, 2013

In my database when an item is currently being loaned the item's loaned field will have a 1 to indicate this. When the item is returned the value is 0. Only so many items are available and when I use the DCount function it is counting the 0s as 1s.

View 1 Replies View Related

Modules & VBA :: Counting Multiple Records And Specific Duplications

Aug 15, 2014

I have a table that contains names of employees and the name of awards they received.

tblEmployeeAwards
EmployeeName, AwardName
John,Nobel
John, Pulitzer
Michael, Fulbright
Jane, Nobel
Jane, Fulbright

I would like to know the following:

1. How many employees received more than one award (answer: 2).
2. How many employees who received the Nobel prize also received any second prize (Answer: 2).
3. How many employees who received the Nobel prize also received the Fulbright (answer: 1).

View 10 Replies View Related

Modules & VBA :: Ignore Date Fields In Table When Counting Records?

Jun 6, 2014

Suppose I have a table with a variety of fields; one autonumber, some text fields and some date fields.

I need code to calculate the number of fields that are NOT date fields and then code to count how many of those fields (the ones that are not date fields) have data in them.

Following is the code to count how many fields in a table had data and this works well, but now I need to find a way to ignore the date fields. How can this code be modified to do the same but ignore the date fields?

Code:
Public Function PercentCompleted(Table As String, IDProject As Long, TotalFields As Single) As Double

Dim sampO As DAO.Recordset, iCtr As Long, strSQL As String, Percent As Double
'Takes the fields based on the projectID
strSQL = "SELECT *" & _
"FROM " & Table & " WHERE IDProject = " & IDProject
Set sampO = CurrentDb.OpenRecordset(strSQL)

[code]....

View 13 Replies View Related

Modules & VBA :: Counting Number Of Occurrences Of Line Feed In Long String

May 1, 2015

I have to count the number of occurrences of Line feed (vbLf) in a long string. The code I am using is:

MAX = TLine.Split(vbLf).Length - 1

It does not work.

View 5 Replies View Related

Counting Of Cases And Counting No Records

Jan 26, 2007

I have a report due the first of each week in which I need the cases open and cases closed for the previous week, the week two weeks prior and the 2007 and 2006 year to date on two different types of cases. I have a case management table with a field for Type of Case, date assigned and date closed that I uses in my queries. Presently I have two query, one that generates only Type 1 cases from the Case Management Table and another for Type 2. I then use the Type 1 Query in another query that limits the results for Type 1 cases to those opened last week, one for those open two weeks ago, one for 2006 YTD and one for 2007 YTD. In these 4 queries I have one field [Type of Cases] and I have the query count. I then do this for Type 2 cases and then go through the whole process to do Closed Cases. All my queries have criteria to automatically filter the dates to the time periods mentioned above. I then have one report query that I put all the number in for my report. This query has 16 fields with the numbers for each period, last week open and closed, 2 weeks open and closed, etc. I then generated a report that takes these numbers from my report query and puts it in a report format automatically. As you can imagine this takes some time to go through each query to generate these numbers, so I was wondering how I may do this differently. Also, I have experienced a problem when a field produces no records I get a blank sceen with nothing under the Count of column and get the same thing for my report. How can I fix this.

View 1 Replies View Related

Counting

May 13, 2005

i am trying to count the number of records based in a query

can some one send me in the right direction

View 2 Replies View Related

Counting

Feb 8, 2006

I have a database where there are numerous fields but they all only have one three values Y, N, N/A.

how do i get something similar to Excels "countif" function to summarise the totals of Y's N's N/A's inach field ?

Thanks

View 1 Replies View Related

Counting

Feb 8, 2006

I have a database where there are numerous fields but they all only have one three values Y, N, N/A.

how do i get something similar to Excels "countif" function to summarise the totals of Y's N's N/A's in each field ?

Thanks

View 4 Replies View Related

Counting

Jan 26, 2007

How can I count the number of times an employee shows up on a report. The final result would be:

Employee 1: Reader1
Employee 1: Reader2
Employee 1: Reader3
Employee 1: Reader4

If an employee shows on a report 4 times, I need it to look like the example above in sequential order, not just a total.

Thanks for your help.

View 1 Replies View Related

Counting Down!

Jan 10, 2006

Hi

I have a form which displays which products are on sale but I want it to count stcok orders down, i.e. if there are 10 stock and someone orders 1 I want the system to automatically recognise that there are only now 9 in stock, any ideas? Help really would be appreciated!

Thanks

B

View 4 Replies View Related

Counting

Apr 18, 2007

Hello,

I have a form called feedback which has three columns and each cell in a column has a combo box that holds (Yes/No/Empty), and I want to count each column's value for example let's supposed that:


feeback number: Column 1 (Are You happy) - Column 2 (Are you sad) - Column 3 (Are you hungry)
1 : Yes - No - Yes
2 : Yes - Yes - Yes
3 : No - No - Yes
4 : empty - No - yes

Counting: the next step is that I want to count:

values in Column 1, where number of Yes =2 , and number of No=1 the stum of Yes + No = 3 and empty = 1
values in Column 2, where number of Yes =1 , and number of No=3 the stum of Yes + No = 4 and empty = 0
values in Column 3, where number of Yes =4 , and number of No=0 the stum of Yes + No = 4 and empty = 0


So, how can I apply this concept in MS ACCESS (2000-2003).

I am waiting for you kindly reply.

View 1 Replies View Related

Counting Summary

May 16, 2005

hi
i have a number of query's (Current memberships, out of date memberships etc) all via a certain area/town.

i am trying to find out total figures (how many members how many non members, how many in certain area/town. these need to be updated continuoulsy.

do not no how to approach i ahve looked at the sigma sign and played with no luck.

should i be looking at another query for totaling or un update qurey, sorry very lost, would like this information also displayed on my record form.

searched all weekend with no luck any ideas.

View 2 Replies View Related

*?? Counting Values In The DB *??

Feb 2, 2006

Hi I have a table that looks like this:

Col1 Col2 Col3 Col4 Col5 Col6
1 A B C D E
2 A B C D F
3 A B C G H
4 A B J K L
5 A D M N P


Does anyone know how I can run an SQL query to count how many letters there are For example : 5 A's 4 B's 3 D's Etc

Cheers,
bikeboardsurf

View 2 Replies View Related

Help Counting Records

Mar 20, 2006

Hi,

I wonder if someone could possibly help me.

I'm working on a database used to dispatch first aiders to events. The general structure is a form detailing the event with a subform (currently pulling info straight from a join table though I may change the data source to a query at a later date) containing details of attendees in list format.

I have a record in the events form that shows the number of first aiders attending which is currently updated manually. In the subform however, there is a tick box as to whether they attended as sometimes they enlist but have to cancel for whatever reason.

I wanted to implement something that will count the ticks and update the number attended field automatically.

I don't know alot about VB and have tried using the count expression function in the subform footer then setting the number attended field to equal the count field. The problem I find with this though is firstly there can sometime be a delay in updating this and secondly I need the number attended to appear in a report listing all the duties attended each month for expense claims.

I may be half way to hitting the mark with what I've tried but if anyone could suggest anything, I'd be very grateful.

Thanks in advance for the help

Ian

View 1 Replies View Related

Counting Occurrences

Sep 1, 2007

I have a table which is basically a calendar containing the columns (i) date, (ii) special info relating to that date (iii) morning volunteers and (iv) afternoon volunteers.

In the "Morning Volunteers" there are up to two names with sometimes a first name, sometimes an initial but always a family name.

The same is true for the "Afternoon Volunteers".

What I want to do is, using the Family name, to find out how many mornings/afternoons each of the volunteers has manned the Visitor Centre.

As I am new to Access I have no idea whether this is possible and, if so, how to do it.

I can do it by exporting the table to Excel but this is very clumsy and time consuming

I am using Vista and Access 2003.

View 1 Replies View Related

Counting By Week

May 29, 2005

What I would like to do is get a count of the product sold and view it over a ten week period in this case week one starts 26th June.

Wk1, Wk2, Wk3 ....

x 10 5 15 etc
y 20 4 12




in the format above but I am not sure how to achieve this, I have the following:


SELECT COURSEBK.[COURSE-DSName], COURSEBK.From, COURSEBK.Description, Count(COURSEBK.[COURSE-DSName]) AS [CountOfCOURSE-DSName]
FROM COURSEBK
GROUP BY COURSEBK.[COURSE-DSName], COURSEBK.From, COURSEBK.Description
HAVING (((COURSEBK.From)>=#6/26/2005# And (COURSEBK.From)<=DateAdd("ww",+10,"26/06/05")))
ORDER BY COURSEBK.From;

(the above is working despite access changing the date format between the hashes)


regards in advance foir guidance

View 5 Replies View Related

Counting Dates

Jul 20, 2005

Okay, this is gonna be weird :o What I'm looking to do is count the dates a preticular training task was accomplished. However, I do not want the dates that are expired to be counted. I will be running this off of a quiry that shows the "due date" of each task. I really have no idea where to start :confused: . Many thanks, Tim

View 2 Replies View Related

Counting Query

Sep 15, 2005

Hi, i have a table with several fields.

I need a query that will display the social security number, and hte number of times it appears for each unique number. how would this be strucutred? thanks

View 1 Replies View Related

Counting The Days

Dec 1, 2005

could someone please help me. ive tried all sorts of things and now im loosing the will to live.
under the data protection act i have 40 days to produce requested files in a hospital. the problem is that my little database that has been working away for 2 years is not capable of flagging up any files that are gone over the limit.

i need to run a query that will bring up all files not completed in the past 40 days. or reaching the forty day limit.

ive tried <now()-40 or <date()-40 in the critieria of the date rquested field. ive also tried kicking the machine when my boss isnt looking. that didnt work either.

im sure this aint rocket science.

samzie

View 3 Replies View Related

Counting Dates

Jan 5, 2006

Here is my table:
tbl_tc
Name
Date
Tech_Name
Issue
Resolved
Resolved_Date
In
Out

I need a query that will do the following:
Total Number of:
Tickets Open (IE, Date field is populated, but Resolved_Date is not)
Tickets Closed (both Date fields are populated)
Total In
Total Out

Total By Tech_Name:
Same as above but I need it seperated by the techs name.

Problem is that I only need it to pull up the Current Months tickets, I will pull additional months later on.

I am not really sure how to even start this... HELP PLEASE!

View 3 Replies View Related

Counting Hits

Jan 18, 2006

I've attached a sample of what I'm trying to do. I want to count the number of hits in the column (each number represents only one hit). For example, Bill had a total of 2 hits. Please help me count the hits.

Thank you.

View 2 Replies View Related

Counting Including 0

Feb 24, 2006

I need to run a query counting how many policies a client cancelled. But I need the query to include zeros. Is this possible?

Here's my SQL Statement currently.

SELECT DISTINCTROW Pqry_CancelledPolicy01.Number, Pqry_CancelledPolicy01.Name, Pqry_CancelledPolicy01.POLICY_STATUS, Count(Pqry_CancelledPolicy01.Number) AS CountOfNumber
FROM Pqry_CancelledPolicy01
GROUP BY Pqry_CancelledPolicy01.Number, Pqry_CancelledPolicy01.Name, Pqry_CancelledPolicy01.POLICY_STATUS
ORDER BY Pqry_CancelledPolicy01.Number;


Thank you in advance for the help.

View 1 Replies View Related

Counting Query

Mar 13, 2006

I have two reports i run every so often in those reports i have a criteria set which asks me to type yearly, lifetime or three year and then after report prints out it also has total member quantity query on top of the page which counts whatever membertype i am typing it in, however right now its only counting yearly members.

I was wondering is there an easy way to just count the yearly members, lifetime and three year separetly on top of my reports?

Member types total count is....

yearly 400
three year 25
lifetime 70

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved