assignment_num field: 1001, 1002, 1003, 1004, 1005
project_num field: 20,20,15,16,15
employee_name field: tom peter, tom peter, tom peter, julie, sally
What I want is to display the employee name with 2 projects or more...
What i have done?
I've done a group by and then count project_num field.. I also added a condition whereby the countofproject_num > 1.. everything went well except that the countofproject_num display 3 instead 2..
Hello, I am new to Access and trying to run a query that will count only unique invoice numbers in my table. I am sure this is an easy command, and thank you for your help!
Code: ' count records in query Dim rs As DAO.Recordset Dim db As Database Dim strSQL As String Dim beginDatum As String Dim eindDatum As String Set db = CurrentDb
I modified a form and now it seems it's impossible to modify/add records. It seems that all comes from when I modified my record source query to add a a field in which it COUNTs all related records in another table. Now the form can't modify anything else but I need to change other fields or add new records! In other words: how can I add a simple box which, for every record of my table/form, counts the number of related records in another table (relationship is 1-to-many, and of course is based on a field in table2) letting me modify and add records? Thank you
SELECT Count(T_STUDENTS.studentsID) AS res1yes, T_COACHING.COACH1res, T_COACHING.COACH1port, T_COACHING.COACHworkgroup FROM T_STUDENTS, T_COACHING WHERE (((T_STUDENTS.res_vrijstelling)=False) And ((T_STUDENTS.stud_year)="1") And ((T_STUDENTS.stud_coach)=forms!F_cboCOACHING!cboCOACHING)) GROUP BY T_COACHING.COACH1res, T_COACHING.COACH1port, T_COACHING.COACHworkgroup;
It runs fine, untill the moment the count is 0. At that point it breaks the form. How can i tell access to deal with this? Somehow i need to replace the count result with 0 if there are no records that meet the criteria.
I've been given a flat-file database to 'improve'. One field is simply titled 'Room' and refers to a room number in a school. I want to create a MakeTable query that will run through all the records and make a table containing one instance of each room number (for normalizing). Hope that makes sense!
I have a set of devices that are assigned to a truck, on occastion they are moved from truck to truck, I need to be able to track where they are AND where they have been. Here is what I have:
ID (autonumber) GPS ID (number, this is the specific ID to each device) Truck Number (this is the specific ID for each truck Installation Date (Date installed / moved)
I have created a query to show the data I need, I have put them in order based on date.
- I must keep each event stored on the table
Goal:
To show a list of the current location of each device, nothing more.
I want to do a unique count of dates when an activity was done in my table. The table may have multiple entries of the activity performed possibly on the same date by an individual
totV = ECount("[dateAssessed]", "R_P_Data_P", "[approvalNoSys] = '" & [Forms]![cmrOverview]![txtappNoSys] & "' AND [Activity] Like '*audit*'") totV = Unique count dateAssessed = date field in R_P_Data_P table R_P_Data_P = table "[approvalNoSys] = '" & [Forms]![cmrOverview]![txtappNoSys] & "' = criteria for the customer in question to separate them from many other customers in the table. Activity = text field in R_P_Data_P table audit = the activity
I'm also trying to avoid having to build total queries etc to them reference them, I'd like getting the desired outcome in an expression or small code.
I read about Ecount but my complier doesn't recognise the function
I have 2 linked tables, tblPN & tblReceivedDate. tblPN has field PN and tblReceivedDate has field [Received Date]. The tables are used to record the receipt of different part numbers and the date they received. I want to use a query to count how many times a part number is received. The catch is that I only want to count a part once even if it is received more than once on the same date. With the data in the attached DB the count for PN 123 would be 5.how to configure the query to do what I need to do?
I have three queries that count non-compliant records in each of three catagories per month. One catagory has records for both Jan and Feb and returns the rersults as follows: Jan 3 Feb 4 The other two vatagories however have no non-compliant records for January so they return as follows: Feb 2 Feb 1 I wanted to tie the three queries together in the form for reporting:
Cat 1 Cat 2 Cat 3 Jan 3 0 0 Feb 4 2 1
Is there any way for the queries to return a zero for any month with no records rather than not returning the month at all? Thanks for any help.
The query returns the parts used for each job. This could be 1 to many, so I get 1 to many rows returned in the query for each job. There can be a number of jobs to a work schedule (I'll call this WS). Each job is for a particular model. So I bascially have
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.
SELECT tblCurrencies.CcyID, tblCurrencies.Ccy FROM tblCurrencies ORDER BY tblCurrencies.Ccy;
Now - I have a separate table of balances, which is linked to the currency table by the same CcyID, and which also has identifiers to link it to other tables (e.g. AccountID)
As part of the above query, I want to return the count of unique AccountID's in the balance table for each currency. So in other words, I want to know, for each currency, how many unique accounts exist?
Each AccountID could appear one or more times in the balance table (one-to-many relationship), so I only want to count the number of unique ID's.
So I started with the following :
Quote:
SELECT tblCurrencies.CcyID, tblCurrencies.Ccy, Count(tblBalances.AccountID) AS NoOfAccounts FROM tblCurrencies INNER JOIN tblBalances ON tblCurrencies.CcyID = tblBalances.CcyID GROUP BY tblCurrencies.CcyID, tblCurrencies.Ccy ORDER BY tblCurrencies.Ccy;
But this just gives the number of AccountID's per currency (regardless of duplication within them)
I found this article which informs me that a Count(Distinct) query won't work in Access and to use subqueries instead.
Code: Dim rs As DAO.Recordset Dim db As Database Dim strSQL As String Set db = CurrentDb strSQL = "SELECT DISTINCT tbl_contract_lev.ContractID FROM (tbl_leverancier_gegevens INNER JOIN
[Code] ....
The result of the query is a list fo unique values but by including the "count" function in SQL seems not te be working in combination with "DISTINCT"...
Dear all i have a problem that i don't know what to do with it? Here it is: i have a cost table in which FO cost is saved.This FO cost is used in different calculation, in different forms. so i create a function called get_FO_cost() as below.
Function get_FO_cost() Dim s As String Dim c, r As Object Dim v As Single Set c = Application.CurrentProject.Connection Set r = CreateObject("ADODB.Recordset") s = "select FO_Cost from Cost_table where month = '" & Me![month] & "'" r.Open s, c, 1 If r.RecordCount <> 0 Then v = r![FO_cost] End If r.Close Set c = Nothing get_FO_Cost = v End Function
when I use this function for calculation then it returns wrong value. for Example: the value in the table for FO_cost = 0.005 ( it has a datatype single in table) then the value in form for this 25 * get_FO_Cost() = 0.124999997206032 but actually 25 * 0.005 = 0.125
when i debug the function code it shows FO_cost value 0.005, but when the debug is over the calculated value i.e. 25 * get_FO_Cost() is 0.124999997206032
I have a function which I want to return the value of a field.
Public Function fieldValue(tblName As String, fldName As String) Dim drs As Recordset Set db = CurrentDb Set drs = db.OpenRecordset(tblName) fieldValue = drs.Fields(fldName).Value drs.Close Set drs = Nothing End Function
I need to return the value obtained, for a specified User identified with a numeric variable.What is the best way forward? - Some sort of filter or DLookup and how to code this?
Trying to figure this out, but I’m not getting anywhere.
I have 2 tables one is just a list of options that can be used in a drop down box in the other table.
What I am trying to do is create a query that will count how many times the words from the first have been used in the second query. I have been able to get it to count how many times the word has been used but I also need it to return a 0 if the word has not been used.
In my query I used both tables to try to do this but it only returns the ones that have been used.
I will attach the DB if someone is willing to take a quick look at it to see if they can get it to work.
I display some buttons on my Form. I should do an SQL request to know how many and what the button should display. It works fine with a RecordSet. Now I want to move the code that do the stuff to a function. I read that I can't return a pointer to a RecordSet and I should used a variant with a getrows.
So I try this :
*here is my function
Function get_nom_operation(ByVal cnn As ADODB.connection) As Variant Dim requetteSQL As String Dim rst As New ADODB.Recordset
Set res = get_nom_operation(conn) Dim i As Integer 'i = 1
For i = LBound(res) To UBound(res)
Set Obj = Me.Controls.Add("forms.CommandButton.1") With Obj .Name = "monButton" & i .Object.Caption = res(0,i) .Left = 14 .Top = 25 * i .Width = 60 .Height = 20 End With
'ajout de l'objet dans la classe Set Ge = New gere_event Set Ge.CButton = Obj Collect.Add Ge i = i + 1
Next
But it doesn' work, and I don't know why...
The error doesn't show where the code is stoped, but only show the call to display this form.
someone could show me some way to find the solution please ?
I would like to select a case depending on the output of a function.
This function tests the syntax of the reporting month.
If the syntax is fine nothing should be done further in the main sub else it should return to the Input window for the reporting month.
Somehow it doesn't work out.
Code: Public Function RepMonthCheck(rep_date As String) as Boolean If Len(rep_date) <> 6 Or Left(rep_date, 2) > 12 Or Left(rep_date, 2) < 1 Then MsgBox ("Reporting rep_date is not in the correct format = mmyyyy") Return False ElseIf Right(rep_date, 4) > 9998 Then MsgBox ("No forecast available for year 9998")