I hve a query that I want to total soldAtPrice *quantity This information is stored in my order details table and mus not change .I can do a calculated field to get the answer but the Problem is if there are 2 recodrs to be totaled the query displays 2 records if there are 3 records the query dislplays 3 records and so on .I need one record to be displayed with the total of all the recodrs
I have a database which holds information about repairs. Each repair is called a task and among other things data is held about things(s) that caused the failure and what need to be replaced. Usually it's one fault but it could be many.Replacements are usually more than 1. Bottom line, in a simplistic view, I have 3 tables task, fails and replacements. There is one to many relationship between tasks and fails and also a one to many relationship between tasks and replacements.
If there is one fail and many replacements my query is good enough as it will produce
I have a load of data in an excel spread sheet that I'm trying to put into an access using Excel VBA (Jet/ACE SQL I think!?). I do this by constructing INSERT INTO strings and looping through my spread sheet. Let's say the primary key is associated with the field [Company] which holds the company names. A simplified version of what I was using (it all works great ) is below:
Code: Set rs = New ADODB.Recordset Set cn = New ADODB.Connection cn.ConnectionString = GetConnectionString() cn.Open cn.Execute strSQL
where strSQL =
Code: INSERT INTO tblTestMDB ([Company], [Date]) VALUES ('BP', '30/09/2012')
Unfortunately, I am having issues with users adding the same company twice. I'd like it to:
- update the existing company info if the company already exists - add the company if it is not already there.
I'm trying to do it in two stages. First an update, then an add. The first part works great :
Code: UPDATE tblTestMDB SET [Date]='21/03/2015' WHERE [Company]='BP';
The second part: (I have tried numerous variations on the syntax):
Code: INSERT INTO tblTestMDB ([Company], [Date]) VALUES ('BP', '30/09/2012') WHERE NOT EXISTS (SELECT * FROM tblTestMDB WHERE [Company] = 'BP');
I find the error messages rather cryptic but they include things like "Query input must contain at least one table or query." or "Missing semicolon ( ; ) at end of SQL statement." (<== No I'm not!?
I have a mismatch Query that shows time slots available during day that have not been booked (15 minute intervals) the problem I have i want to just show the time slots that are available depending on what treatment has been chosen so if it was a one hour appointment then it checks that 4 slots available in a row and just displays that
Available 11:00 11:15 12:00 12:15 12:30
How I would try to do this 12:45 13:00 13:15 13:30
so would show for a 1 hour appointment 12:00 12:15 12:30
i have a combo box ,and when i should select "all",this button after update code should show me all the column of table test ,but looks like for no reason the record set shows nothing and its not working.
Code:
Private Sub cboTaskListName_AfterUpdate() 'On Error GoTo cboTaskListName_AfterUpdate_Err Me.Refresh Dim db As DAO.Database Dim SQL As String Dim rs As DAO.Recordset If Me.cboTaskListName = "111111" Then Set db = CurrentDb() SQL = "SELECT no1 from test" Set rs = CurrentDb.OpenRecordset(SQL, dbOpenDynaset) End If End Sub
I'm trying to count the number of records within a region range using a lookup table however I keep getting duplicate values, SQL code, what is happening:
SELECT Count([summary].Key) AS CountKey FROM Summary, lookup WHERE ([Region])) Between [Region 1] And [Region 2]));
I have a question on hiding duplication record using query.
The fields in the query are:
full name(trainee), NRIC(trainee), gender(trainee), preferred language(trainee), company(trainee), course name(course), course date(course), competent(course), class(course), L3 survey(trainee), L4 survey(trainee), num of month(course)
When the query is being run, it will show all the people that have not done the L3 and L4 survey after 3 month. The the query will be convert into a form. However the problem is that the record will show a few same name due to one person can take more than 1 course. therefore, the data in the course table will always be different.
How can i make the record only show 1 name even though they have different course name.
I had tried putting 'yes' for unique record and unique value but it did not change the result.
current SQL query:
SELECT DISTINCT trainee.[Full Name], trainee.NRIC, trainee.Gender, trainee.[Preferred Language], trainee.Company, course.[Course Name], course.[Course Date], course.Competent, course.Class, trainee.[L3 survey], trainee.[L4 survey], DateDiff('m',[Course Date],Date()) AS [Num of Month] FROM trainee INNER JOIN course ON trainee.NRIC = course.NRIC WHERE (((course.Competent)="c") AND ((trainee.[L3 survey])=False) AND ((DateDiff('m',[Course Date],Date()))>=3)) OR (((trainee.[L4 survey])=False) AND ((DateDiff('m',[Course Date],Date()))>=6));
Im trying to write a query that shows all the container movements. Yet when I run the query qryFullHistory I get a duplicate value for container Off Island. Ive tried adding some criteria that says that the DateRequested has to be between the ImportDate and ExportDate but that doesnt seem to work. There are duplicate entries for container Off Island in tblContainerDetails as the same container has arrived and left and then returned on another voyage. Yet there is no entry for the second voyage in the tblMEMRContainer.
A brief description of the tables is: tblMEMR Movement requests details tblMEMRContainers the containers that were moved on the movement request. There can be more than 1 container for each request. tblContainerDetails details and dates for the container when it arrived and when it left
There are other tables but these are the 3 that are used in the query.
I am trying to create a query to find duplicates and delete the duplicates. The result will eventually be used in another query (append query) to update a table.I have a table with 4 columns lets say for simplicity they are A, B, C, D
I want my query to find duplicates within B and deleting them. The catch is before deleting them I need to look into column A to ebsure they are actually duplicates. Example below
Example A B John Doe Tires John Doe Wipers Allison Doe Tires Allison Doe Tires
As you can see from the above Tires is a duplicate and need to be deleted.
A B John Doe Tires John Doe Wipers Allison Doe Tires
Why I am getting duplicate results for some of my records in a query. I have unique values set to Yes. I have also validated that the tables I am using don't have duplicate data. SQL is below.
SELECT DISTINCT [tbl_Rewards Activity Report - By Member Number].[Member Number], [tbl_Rewards Activity Report - By Member Number].[Last Four], [tbl_Rewards Activity Report - By Member Number].[BAL ID], [tbl_Rewards Activity Report - By Member Number].[Primary Name],
I have this small database, I would like to have your support to setup this query "QryResults" in order to remove the duplicate records, I can't find a way to get shown only true records, for some reason I'm getting duplicate rows and fake values, the query is calculating operations from two different queries and a table.
ITEM , SIZE A , 12 B , 12 C ,100 D ,12 E ,100 F ,100 G , 150
I would like to do a query that Joins the "Size" in each table, and then matches an "Item" to a "Location". However, because of how a normal join works, I cannot seem to figure out how to limit the "Location" field from producing duplicates in the match.
I have an Access 2010 table which shows Latitude and Longitude. However instead of it being in a decimal format it is displayed as 4000000000. I need to add a decimal point so that it looks like 40.00000000. If I configure the Field Properties to Decimal with a scale of eight and decimal places set to eight I can manually convert all of the data to the correct format. But I would like to have this happen automatically from a query.
Hello, How would I go about in making a command button bring up a report to show a result of items for the end of the month? For example, when a user clicks on this button it will bring up a report showing all the items that are out of date for the end of the month. I am having problems with the query as for months have different lengths e.g. 28/29/30/31 days. How would I make a query show the end result for each month correct as February if going to be different each time i.e. when it is a leap year. I have got far but having trouble with this part. Hope you can help.
I have a database that reuses many queries in several different macro's. Any way to generate a report, (or purchase an add-in), that will show for each query any other queries that use it. It would be ideal to show all of the "cascading" queries that one query is built on. It just gets confusing when I need to tweak a query to then have to figure out there are other queries that use the one that's being tweaked and the tweak will change the results of the other queries.
This is a very quick question. I have a query what i need it to do is show me all values that equal 2 and any records that are blank, this is what the criteria looks like currently
Field: Month([FDate])
Total:Group By
Criteria: Month([DDay1])
Now the way this works is it only shows records where the field meets the criteria, in this case Month([FDate]) = 2
I need the criteria to say if Month([DDay1])=Month([FDate]) Or is equal to "" Then display records.
EDIT: I just found out how to view blank values but what if records for it dont even exist... i still want to show the other fields..
I have a totals query that shows results in a chart. It takes a parameter to limit results, by a combobox in a form.
Parameter in the query includes the OR "*" expression, in case someone wants to get the results unfiltered.
The Combobox in the form, has an AfteUpdate event that opens the chart (form) every time its value changes, by the [DoCmd.OpenForm "ChartForm" , acNormal] expression.
I don't know how to make it open the ChartForm when no parameter is selected in the combobox.
I'm trying to determine the SQL to return only those records in a table which have duplicate values in each of two fields, but different values in a third field. Here's an example:
Code:
AcctNum FoodType FoodClass ------- -------- --------- A123 Apple Fruit A123 Apple Fruit A123 Grape Fruit A456 Potato Vegetable A456 Potato Perishable A789 Carrot Vegetable A001 Banana Fruit
For the above table, I'm trying to return records which have multiple entries for AcctNum + FoodType, but DIFFERENT values for FoodClass. So for the above table, the query would return:
It returns these two records because there is more than one record with for the AcctNum + FoodType (i.e. 'A456' + 'Potato'), but DIFFERENT values for FoodClass (i.e. one record has 'Vegetable' while the other has 'Perishable').
I am trying to run graph on a report from query but what's happening is query shows name but report on graph shows ID'S of the field .
Below is my query
SELECT tblMainTWTTPSheet.txtRootCause, Count(tblMainTWTTPSheet.txtRootCause) AS CountOftxtRootCause FROM tblMainTWTTPSheet GROUP BY tblMainTWTTPSheet.txtRootCause, tblMainTWTTPSheet.Date HAVING (((tblMainTWTTPSheet.txtRootCause) Is Not Null) AND ((Count(tblMainTWTTPSheet.txtRootCause)) Is Not Null) AND ((tblMainTWTTPSheet.Date) Between [Forms]![frmStratificationOfRootCauses]![startDate] And [Forms]![frmStratificationOfRootCauses]![endDate]));
My bound column on main menu form and back end table is 1
I thought I had just about finished my DB but now Ive printed out and checked my reports I notice I have several records in different types of reports showing duplicate records. Iv'e gone back over the queries and there are one or two duplicates in several of my queries that I did not notice before because there are are only the odd one or two. No matter what I do I can't stop this happening. I think it must be something to do with the dates in my payment table. PaymentID is key field - foreign key is MemberID. One member can have several paymentID's a new one every year when membership renewed. The problem seems to be when the member has two payment dates in the same year. This shouldn't be anyway but the database has not been used properly with entry dates missing, written over of wrong dates etc. Ive tried to correct this but do not want to tamper with past payment date records. I already have 'select distinct' in my queries and have tried 'distinct row' which seems to return even more duplicate records. Im pulling my hair out over this there must be a way to return the records from members showing just 1 only of their very latest payment record/date. Im using this expression in the query.
LastPaid: (SELECT MAX(PaymentDate) FROM S_Payments_Table WHERE S_Payments_Table.MemberID =S_Members_Table.MemberID)
I have been hitting my head against the wall to have my query not show any DUPLICATE STOCK CODES in my report..I have two "AQN.PR.A" records, I only want my report to print one "AQN.PR.A"...I have three "ALA" records, I only want my report to print one "ALA"AQN.PR.A