Union Query Datasheet Not Updateable

Mar 19, 2008

Hello All,
I have a database with multiple tables, each table with a subset of common fields I need to work with. The way the database was set up was a series of append queries that created a common table to combine the subset of fields. The problem with this is that I had to work with the common table but update the data in the parent tables and regenerate common table to keep everything up to date. To get around this I have created a union query to replace the common table but the data is not updatable. I have had a quick scan of the net and it seems union queries are not updateable by default. I understand the problem I have is a result of the database not being structured correctly however due to circumstances beyond my control, I am stuck with it. I have come across a couple of INSTEAD OF trigger examples but not sure quite how they work and if they can help me. Below is the SQL code for my union query so any help in making it updatable would be greatly appreciated.

Regards

Daz

SELECT [Belt Filter Press].Table, [Belt Filter Press].Plant, [Belt Filter Press].[New Tag], [Belt Filter Press].[New Comment],

[Belt Filter Press].[P&ID number], [Belt Filter Press].Purpose, [Belt Filter Press].[Motor Size], [Belt Filter Press].Starting, [Belt

Filter Press].New, [Belt Filter Press].Comment, [Belt Filter Press].Switchboard, [Belt Filter Press].PLC, [Belt Filter

Press].[PLC Interface], [Belt Filter Press].ACH, [Belt Filter Press].IL, [Belt Filter Press].ZSO, [Belt Filter Press].WIO, [Belt

Filter Press].ZSP, [Belt Filter Press].PSL, [Belt Filter Press].FSL, [Belt Filter Press].TSH, [Belt Filter Press].MSX, [Belt Filter

Press].SSL
FROM [Belt Filter Press];

UNION SELECT Bins.Table, Bins.Plant, Bins.NewTag, Bins.[New Comment], Bins.[P&ID number], Bins.Purpose, Bins.[Motor

Size], Bins.Starting, Bins.New, Bins.Comment, Bins.Switchboard, Bins.PLC, Bins.[PLC Interface], Bins.ACH, Bins.IL,

Bins.ZSO, Bins.WIO, Bins.ZSP, Bins.PSL, Bins.FSL, Bins.TSH, Bins.MSX, Bins.SSL
FROM Bins;

UNION SELECT [Chemical Dosing].Table, [Chemical Dosing].Plant, [Chemical Dosing].[New Tag], [Chemical Dosing].[New

Comment], [Chemical Dosing].[P&ID number], [Chemical Dosing].Purpose, [Chemical Dosing].[Motor Size], [Chemical

Dosing].Starting, [Chemical Dosing].New, [Chemical Dosing].Comment, [Chemical Dosing].Switchboard, [Chemical

Dosing].PLC, [Chemical Dosing].[PLC Interface], [Chemical Dosing].ACH, [Chemical Dosing].IL, [Chemical Dosing].ZSO,

[Chemical Dosing].WIO, [Chemical Dosing].ZSP, [Chemical Dosing].PSL, [Chemical Dosing].FSL, [Chemical Dosing].TSH,

[Chemical Dosing].MSX, [Chemical Dosing].SSL
FROM [Chemical Dosing];

UNION SELECT Clarifiers.Table, Clarifiers.Plant, Clarifiers.[New Tag], Clarifiers.[New Comment], Clarifiers.[P&ID number],

Clarifiers.Purpose, Clarifiers.[Motor Size], Clarifiers.Starting, Clarifiers.New, Clarifiers.Comment, Clarifiers.Switchboard,

Clarifiers.PLC, Clarifiers.[PLC Interface], Clarifiers.ACH, Clarifiers.IL, Clarifiers.ZSO, Clarifiers.WIO, Clarifiers.ZSP,

Clarifiers.PSL, Clarifiers.FSL, Clarifiers.TSH, Clarifiers.MSX, Clarifiers.SSL
FROM Clarifiers;

UNION SELECT Filters.Table, Filters.Plant, Filters.[New Tag], Filters.[New Comment], Filters.[P&ID number], Filters.Purpose,

Filters.[Motor Size], Filters.Starting, Filters.New, Filters.Comment, Filters.Switchboard, Filters.PLC, Filters.[PLC Interface],

Filters.ACH, Filters.IL, Filters.ZSO, Filters.WIO, Filters.ZSP, Filters.PSL, Filters.FSL, Filters.TSH, Filters.MSX, Filters.SSL
FROM Filters;

UNION SELECT [Gravity Drainage Deck].Table, [Gravity Drainage Deck].Plant, [Gravity Drainage Deck].[New Tag], [Gravity

Drainage Deck].[New Comment], [Gravity Drainage Deck].[P&ID number], [Gravity Drainage Deck].Purpose, [Gravity Drainage

Deck].[Motor Size], [Gravity Drainage Deck].Starting, [Gravity Drainage Deck].New, [Gravity Drainage Deck].Comment,

[Gravity Drainage Deck].Switchboard, [Gravity Drainage Deck].PLC, [Gravity Drainage Deck].[PLC Interface], [Gravity Drainage

Deck].ACH, [Gravity Drainage Deck].IL, [Gravity Drainage Deck].ZSO, [Gravity Drainage Deck].WIO, [Gravity Drainage

Deck].ZSP, [Gravity Drainage Deck].PSL, [Gravity Drainage Deck].FSL, [Gravity Drainage Deck].TSH, [Gravity Drainage

Deck].MSX, [Gravity Drainage Deck].SSL
FROM [Gravity Drainage Deck];

UNION SELECT [Grit Classifiers].Table, [Grit Classifiers].Plant, [Grit Classifiers].[New Tag], [Grit Classifiers].[New Comment],

[Grit Classifiers].[P&ID number], [Grit Classifiers].Purpose, [Grit Classifiers].[Motor Size], [Grit Classifiers].Starting, [Grit

Classifiers].New, [Grit Classifiers].Comment, [Grit Classifiers].Switchboard, [Grit Classifiers].PLC, [Grit Classifiers].[PLC

Interface], [Grit Classifiers].ACH, [Grit Classifiers].IL, [Grit Classifiers].ZSO, [Grit Classifiers].WIO, [Grit Classifiers].ZSP, [Grit

Classifiers].PSL, [Grit Classifiers].FSL, [Grit Classifiers].TSH, [Grit Classifiers].MSX, [Grit Classifiers].SSL
FROM [Grit Classifiers];

UNION SELECT Instruments.Table, Instruments.Plant, Instruments.[New Tag], Instruments.[New Comment],

Instruments.[P&ID Number], Instruments.Purpose, Instruments.[Motor Size], Instruments.Starting, Instruments.New,

Instruments.Comment, Instruments.Switchboard, Instruments.PLC, Instruments.[PLC Interface], Instruments.ACH,

Instruments.IL, Instruments.ZSO, Instruments.WIO, Instruments.ZSP, Instruments.PSL, Instruments.FSL, Instruments.TSH,

Instruments.MSX, Instruments.SSL
FROM Instruments;

UNION SELECT Mixer.Table, Mixer.Plant, Mixer.[New Tag], Mixer.[New Comment], Mixer.[P&ID number], Mixer.Purpose,

Mixer.[Motor Size], Mixer.Starting, Mixer.New, Mixer.Comment, Mixer.Switchboard, Mixer.PLC, Mixer.[PLC Interface],

Mixer.ACH, Mixer.IL, Mixer.ZSO, Mixer.WIO, Mixer.ZSP, Mixer.PSL, Mixer.FSL, Mixer.TSH, Mixer.MSX, Mixer.SSL
FROM Mixer;

UNION SELECT [Odour Control].Table, [Odour Control].Plant, [Odour Control].[New Tag], [Odour Control].[New Comment],

[Odour Control].[P&ID number], [Odour Control].Purpose, [Odour Control].[Motor Size], [Odour Control].Starting, [Odour

Control].New, [Odour Control].Comment, [Odour Control].Switchboard, [Odour Control].PLC, [Odour Control].[PLC Interface],

[Odour Control].ACH, [Odour Control].IL, [Odour Control].ZSO, [Odour Control].WIO, [Odour Control].ZSP, [Odour

Control].PSL, [Odour Control].FSL, [Odour Control].TSH, [Odour Control].MSX, [Odour Control].SSL
FROM [Odour Control];

UNION SELECT [Pump List].Table, [Pump List].Plant, [Pump List].[New Tag], [Pump List].[New Comment], [Pump List].[P&ID

number], [Pump List].Purpose, [Pump List].[Motor Size], [Pump List].Starting, [Pump List].New, [Pump List].Comment,

[Pump List].Switchboard, [Pump List].PLC, [Pump List].[PLC Interface], [Pump List].ACH, [Pump List].IL, [Pump List].ZSO,

[Pump List].WIO, [Pump List].ZSP, [Pump List].PSL, [Pump List].FSL, [Pump List].TSH, [Pump List].MSX, [Pump List].SSL
FROM [Pump List];

UNION SELECT [Safety Shower].Table, [Safety Shower].Plant, [Safety Shower].[New Tag], [Safety Shower].[New Comment],

[Safety Shower].[P&ID number], [Safety Shower].Purpose, [Safety Shower].[Motor Size], [Safety Shower].Starting, [Safety

Shower].New, [Safety Shower].Comment, [Safety Shower].Switchboard, [Safety Shower].PLC, [Safety Shower].[PLC

Interface], [Safety Shower].ACH, [Safety Shower].IL, [Safety Shower].ZSO, [Safety Shower].WIO, [Safety Shower].ZSP,

[Safety Shower].PSL, [Safety Shower].FSL, [Safety Shower].TSH, [Safety Shower].MSX, [Safety Shower].SSL
FROM [Safety Shower];

UNION SELECT [Screenings Equipment].Table, [Screenings Equipment].Plant, [Screenings Equipment].[New Tag],

[Screenings Equipment].[New Comment], [Screenings Equipment].[P&ID number], [Screenings Equipment].Purpose,

[Screenings Equipment].[Motor Size], [Screenings Equipment].Starting, [Screenings Equipment].New, [Screenings

Equipment].Comment, [Screenings Equipment].Switchboard, [Screenings Equipment].PLC, [Screenings Equipment].[PLC

Interface], [Screenings Equipment].ACH, [Screenings Equipment].IL, [Screenings Equipment].ZSO, [Screenings

Equipment].WIO, [Screenings Equipment].ZSP, [Screenings Equipment].PSL, [Screenings Equipment].FSL, [Screenings

Equipment].TSH, [Screenings Equipment].MSX, [Screenings Equipment].SSL
FROM [Screenings Equipment];

UNION SELECT Screens.Table, Screens.Plant, Screens.[New Tag], Screens.[New Comment], Screens.[P&ID number],

Screens.Purpose, Screens.[Motor SIze], Screens.Starting, Screens.New, Screens.Comment, Screens.Switchboard,

Screens.PLC, Screens.[PLC Interface], Screens.ACH, Screens.IL, Screens.ZSO, Screens.WIO, Screens.ZSP, Screens.PSL,

Screens.FSL, Screens.TSH, Screens.MSX, Screens.SSL
FROM Screens;

UNION SELECT [Surface Aerator].Table, [Surface Aerator].Plant, [Surface Aerator].[New Tag], [Surface Aerator].[New

Comment], [Surface Aerator].[P&ID number], [Surface Aerator].Purpose, [Surface Aerator].[Motor Size], [Surface

Aerator].Starting, [Surface Aerator].New, [Surface Aerator].Comment, [Surface Aerator].Switchboard, [Surface Aerator].PLC,

[Surface Aerator].[PLC Interface], [Surface Aerator].ACH, [Surface Aerator].IL, [Surface Aerator].ZSO, [Surface Aerator].WIO,

[Surface Aerator].ZSP, [Surface Aerator].PSL, [Surface Aerator].FSL, [Surface Aerator].TSH, [Surface Aerator].MSX, [Surface

Aerator].SSL
FROM [Surface Aerator];

UNION SELECT Tanks.Table, Tanks.Plant, Tanks.[New Tag], Tanks.[New Comment], Tanks.[P&ID number], Tanks.Purpose,

Tanks.[Motor Size], Tanks.Starting, Tanks.New, Tanks.Comment, Tanks.Switchboard, Tanks.PLC, Tanks.[PLC Interface],

Tanks.ACH, Tanks.IL, Tanks.ZSO, Tanks.WIO, Tanks.ZSP, Tanks.PSL, Tanks.FSL, Tanks.TSH, Tanks.MSX, Tanks.SSL
FROM Tanks;

UNION SELECT [UV System].Table, [UV System].Plant, [UV System].[New Tag], [UV System].[New Comment], [UV

System].[P&ID number], [UV System].Purpose, [UV System].[Motor Size], [UV System].Starting, [UV System].New, [UV

System].Comment, [UV System].Switchboard, [UV System].PLC, [UV System].[PLC Interface], [UV System].ACH, [UV

System].IL, [UV System].ZSO, [UV System].WIO, [UV System].ZSP, [UV System].PSL, [UV System].FSL, [UV

System].TSH, [UV System].MSX, [UV System].SSL
FROM [UV System];

UNION SELECT Valves.Table, Valves.Plant, Valves.[New Tag], Valves.[New Comment], Valves.[P&ID number],

Valves.Purpose, Valves.[Motor Size], Valves.Starting, Valves.New, Valves.Comment, Valves.Switchboard, Valves.PLC,

Valves.[PLC Interface], Valves.ACH, Valves.IL, Valves.ZSO, Valves.WIO, Valves.ZSP, Valves.PSL, Valves.FSL, Valves.TSH,

Valves.MSX, Valves.SSL
FROM Valves;

View Replies


ADVERTISEMENT

Creating Updateable Datasheet Based On Mult. Queries

Feb 12, 2006

Hello all,

I have a scheduling database that I am only using one table "DateLog"

It contains these fields:
JobIDInt-PK
LotIDTxt-PK
TaskIDInt-PK - List from TaskList Table
TripIDInt-PK
TaskDateDate
ForemanIDInt - List from Foreman Table
TaskQtyInt
TaskMisc1Txt
TaskMisc2Txt
NotesMemo


Every time a trip is taken to a job site, a record is created. I would like to have a datasheet view of this table that will join all of the tasks for a particular JobID and LotID together on the same record for easy viewing.
The list of tasks are static and will not change from job to job. The only fields that needs to be seen are the JobID and LotID at the row header. The rest of the data is the TaskDate for each task.

What I have attempted so far is to create a separate query for each TaskID and then to join them by the JobID and LotID. I have gotten to the point that I can put values into the datasheet, but I get an error that the primary key cannot be null.

Am I approaching this the correct way? Is there a way I can point the hidden key fields to the fields they are joined to? Access does not seem to be smart enough to figure this out itsself and I am not sure how to tell it to create the new record using the fields that it is related to.

This is very difficult to explain, any help would be greatly appreciated. I will be glad to post further clarification if I did a bad job explaining what I am trying to do.

Thanks,
Rob

View 3 Replies View Related

Queries :: UNION / UNION ALL Query Crashed Access

Oct 24, 2013

I'm having a problem with a UNION / UNION ALL query.It seems there is a application crash fault when running the query that MS are aware of and have issued a hot fix. Unfortunately it will take my IT dept some time to check and install the hot fix If they agree to do it at all.

Problem signature:
Problem Event Name: APPCRASH
Application Name: MSACCESS.EXE
Application Version: 12.0.6606.1000

[code]...

View 1 Replies View Related

Query Not Updateable?!?

Sep 29, 2005

I have a form that is based on a query that has all of the sudden become non-updateable. After searching this site for a while - I found someone who had a similar problem, it was reccomended to check the query the form is based on to see if it could be updated. I did that with mine and the query COULD NOT be updated either.

To the best of my knowledge - nothing has changes with the tables the query is based off of or the query itself.

Any ideas what else to look for?

View 3 Replies View Related

Query Not Updateable

Oct 18, 2007

Having a problem that's driving me nuts

I am trying to ship some inventory from a sales order line (query 2qryInvShip works fine) but when I join the query with another (to find the oldest stock) Shipped Qty, Shipped Location & Shipped checkbox cannot be updated

Any thoughts as to where I am going wrong with this much appreciated, I have have tried seemingly endless combinations of join types etc but to no avail

db attached

View 7 Replies View Related

Predicate For Non-updateable Query...

May 17, 2005

Okay, it may seem like a silly question for one who's been using this as long as I but I was just curious if anyone had a concise answer as to the predicate for a non-updateable query?

Today I think I decided to stop using a workaround by creating a temporary table with duplicate information found elsewhere in the system.

~Chad

View 1 Replies View Related

Operation Must Use An Updateable Query?

Mar 7, 2006

Hello,

I was hoping someone on this forum might be able to help me.

I am trying to update a table with info in another table, using a nested query.

strSQL = "UPDATE tblTemp SET AdminNum = '" & cboAdmin.Text & "', " & _
"Size = (SELECT Size FROM tblEquipList WHERE AdminNum = '" & cboAdmin.Text & "')"

DoCmd.RunSQL strSQL

cboAdmin is a combo box on my form that is populated by tblEquipList.AdminNum.

When run this gives me:
Runtime Error '3073':
Operation must use an updateable query.

The SELECT statement works by itself, and the first part of the UPDATE (without the nested select) works by itself, but not when I combine them. I also need to update other things in the same manner in which Size is being updated, but when I can get this to work it shouldn't be a problem just added the updates for the other fields in there.

Thanks in advance,
Jeremiah


Edit:
Also, I figured I should add that when I remove the SELECT statment and put in a number (IE: Size = '400'), the query runs just fine. So I know the problem lies in the nesting, but am unsure how.

View 7 Replies View Related

Problem With Updateable Query

Jun 1, 2007

Hi everyone,

I have four tables (all linked by a unique identifier) which I populate via data entry forms. I would like to give the user an option of making changes to the data by entering the unique identifier and displaying the specific record (from all four tables).

Is there any way to write an updateable query to accomplish this task?

I started with a query of two tables and this was updateable.

I then added a third table and now it don't work.

Here's the SQL statement
-----------------------------------------------------------------
SELECT tblPerson.*, tblPermaddr.*, tblTempaddr.*
FROM (tblPerson INNER JOIN tblPermaddr ON tblPerson.FILENO = tblPermaddr.FILENO) INNER JOIN tblTempaddr ON tblPerson.FILENO = tblTempaddr.FILENO
WHERE (((tblPerson.FILENO)=[enter fileno]));
-----------------------------------------------------------------

Any suggestions??


Many thanks in advance.

Will

View 1 Replies View Related

Operation Must Use An Updateable Query.

Mar 21, 2006

I have tried to create a form page that when filled in by a user updates a database.

However i get his error messge

Code:Error Type:Microsoft OLE DB Provider for ODBC Drivers (0x80004005)[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query./tpvsite/RegisterUser.asp, line 62

In my page it aligns to this line objRS.Update. Which i think means there is a problem with my database as anyone any ideas how to fix this. (all my tables and fields are correct)

Cheers

View 5 Replies View Related

Operation Must Be Updateable Query Error?

Mar 9, 2006

Can someone tell me why this query is causing this error? I don't understand it:

UPDATE 1_2_06 SET ROLE = (SELECT ROLE FROM UserRoleData WHERE USERNAME=ASSIGNED_TO)
WHERE EXISTS (SELECT ROLE FROM UserRoleData WHERE USERNAME=ASSIGNED_TO);

thank you

View 1 Replies View Related

Operation Must Use An Updateable Query - MS Access.

Nov 16, 2004

I am trying to update rows in an access database by retrieving data from dynamic text boxes created through a loop. I keep getting the error message: System.Data.OleDb.OleDbException: Operation must use an updateable query. My code is as follows:

Dim myInsertQuery AsString

myInsertQuery = "INSERT INTO tblTestQues (Answer) Values ("txt" & loop1);"

Dim myCommand2 AsNew OleDbCommand(myInsertQuery)

myCommand2.Connection = MyConnection

MyConnection.Open()

myCommand2.ExecuteNonQuery()

myCommand2.Connection.Close()

Please help or contact me if you need more information. Thanks in advanced.

View 3 Replies View Related

ERROR: Operation Must Use An Updateable Query.

Mar 25, 2007

asp code:
Code:<%Set Con = Server.CreateObject("ADODB.Connection") Con.Open "db"dim username, password, mailusername = Request.form("username")password = Request.form("password")mail = Request.form("mail")sql= "INSERT INTO users(username) values('" & username & "')"Con.Execute sqlCon.closeset Con = nothing%>

error:
Code:Error Type:Microsoft OLE DB Provider for ODBC Drivers (0x80004005)[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query./site/content/register_act.asp, line 13

It's says it has something to do with permissions...

I set writing & reading permissions for the db and the directory that contains it through
contorl panel->Administrative Tools->Internet Information Services

I have no "security tab" when I rightclick->properties the db file or it's directory even though the file system is NTFS

in spite all these when I rightclick->properties the directory that contains the db I see a "read only" square marked in the general tab-attributes, when I try to unmark it seems to be unmarked but when I rightclick->properties again it's marked again...

what should I do?

View 1 Replies View Related

Update Query - Operation Must Use An Updateable Query

Jan 8, 2007

Hi,

As an Access novice I am trying to do a simple update of a table but keep getting an annoying error:

I have 2 tables - Products and OrderDetails

Products
ProductID
Description
StockQuantity

OrderDetails
OrderID
ProductID
Quantity

Basically I want to update the Products.StockQuantity column to subtract the sum of all orders in the OrderDetails table.

So if Product A started with a StockQuantity of 5, and there are 3 Order_Details record, each with a quantity of 2, the query should update the Products.StockQuantity record to -1.

I have tried a few permutations such as:

UPDATE PRODUCTS
set PRODUCTS.StockQuantity = PRODUCTS.StockQuantity - (
SELECT SUM(OrderDetails.Quantity)
FROM ORDERDETAILS
WHERE ORDERDETAILS.ProductID = PRODUCTS.ProductID);

but I seem to keep getting the following error:
"Operation must use an updateable query"

Help - I'm tearing my hair out here!!

Thanks,

Keith

View 4 Replies View Related

UNION Query MS Jet Database Engine Cannot Find The Input Table Or Query.

Oct 28, 2005

Hello All,

I'm trying to run a UNION query that joins five queries through a MS WorkSpace into a DAO.recordset in VB. I'm pulling the data from a SQL Server Database through VB in Access. I'm attempting to open a recordset with a query passed to it as a string. The query is below. For some reason, I'm receiving a message: "MS Jet database engine cannot find the input table or query. Runtime Error 3078".

Here's what's puzzling. When I run a single query without any UNION statement, the code finds the table and runs fine without error, but anytime I join two or more queries with a UNION statement in the VB, it gives me the error.

I've executed the same UNION query in both Access Query Builder and SQL Server's Query Analyzer and they work fine in both environments. It's only when I call the query from a DAO.Recodset with VB that it causes this problem. The following is a sample of the UNION query joining two of the five queries. Does anyone have any idea what could be the problem? The following query executes in about 5 seconds so I don't think there's a "time-out" issue. I'm thinking that the UNION statement may be the culprit. Maybe there's another way to approach joining these separate queries? Any help would be most appreciated. Thanks.

SELECT SalespersonID, Sum([SlsPrice]-[RtnPrice]-[SlsDiscnt]+[RtnDiscnt]) AS fldPrice FROM MyTable WHERE (((Source)='d') AND ((DistrictID)='01') AND ((CategoryID) = 'HCPROD') AND ((BrandID)<>'CSS')) AND (((BrandID)<>'1356')) AND (((BrandID)<>'1400')) AND (((BrandID)<>'1551')) AND (((BrandID)<>'555')) AND (((BrandID)<>'66'))
AND (TransDate >= 07/01/2005) AND (TransDate <= 07/31/2005) GROUP BY SalespersonID
UNION
SELECT SalespersonID, Sum([SlsPrice]-[RtnPrice]-[SlsDiscnt]+[RtnDiscnt]) AS fldPrice FROM MyTable WHERE (((Source)='d') AND ((DistrictID)='01') AND ((ProductID) = '0029800')) AND (TransDate >= 07/01/2005) AND (TransDate <= 07/31/2005) GROUP BY SalespersonID

Set wrkJet = CreateWorkspace("", "pw", "", dbUseJet)
Set db = wrkJet.OpenDatabase("DW", _
dbDriverNoPrompt, True, _
"ODBC;DATABASE=DW;DSN=DW2")
'Set rs1 = db.OpenRecordset(strSQL)

View 9 Replies View Related

SQL Union Query

Aug 18, 2005

I have created a report that provides me with employee expenses for temps per week. The types of expenses have been defined as Ad_hoc amounts.

An SQL union query I have used to combine fields

Adhoc_Code_1 - 3
Adhoc_description_1 - 3
Adhoc_Pay_Amount_1 - 3

(details of full sql query below)

I have tried to run for a particular week which should have 3 expense entries but only 2 have been picked up.

I think this is because both Adhoc_ Pay_Amount_2 and 3 have a value of 6 and the UNION operation will not return duplicate records. I have amended to UNION ALL but all entries are duplicated. Can anyone help?

Thanks

SELECT dbo_Valid_Timesheets.Employer_Ref, dbo_Valid_Timesheets.Personnel_Ref, dbo_Valid_Timesheets.Department, dbo_Valid_Timesheets.Tax_Yr_Proc_By_Payroll, dbo_Valid_Timesheets.Period_Proc_By_Payroll, dbo_Valid_Timesheets.Session_Proc_By_Payroll, dbo_Valid_Timesheets.Adhoc_Code_1, dbo_Valid_Timesheets.Adhoc_Description_1, dbo_Valid_Timesheets.Adhoc_Pay_Amount_1, dbo_Valid_Timesheets.Timesheet_Number
FROM dbo_Valid_Timesheets
WHERE (((dbo_Valid_Timesheets.Adhoc_Pay_Amount_1)<>0));
UNION ALL
SELECT dbo_Valid_Timesheets.Employer_Ref, dbo_Valid_Timesheets.Personnel_Ref, dbo_Valid_Timesheets.Department, dbo_Valid_Timesheets.Tax_Yr_Proc_By_Payroll, dbo_Valid_Timesheets.Period_Proc_By_Payroll, dbo_Valid_Timesheets.Session_Proc_By_Payroll, dbo_Valid_Timesheets.Adhoc_Code_2, dbo_Valid_Timesheets.Adhoc_Description_2, dbo_Valid_Timesheets.Adhoc_Pay_Amount_2, dbo_Valid_Timesheets.Timesheet_Number
FROM dbo_Valid_Timesheets
WHERE (((dbo_Valid_Timesheets.Adhoc_Pay_Amount_2)<>0));
UNION ALL
SELECT dbo_Valid_Timesheets.Employer_Ref, dbo_Valid_Timesheets.Personnel_Ref, dbo_Valid_Timesheets.Department, dbo_Valid_Timesheets.Tax_Yr_Proc_By_Payroll, dbo_Valid_Timesheets.Period_Proc_By_Payroll, dbo_Valid_Timesheets.Session_Proc_By_Payroll, dbo_Valid_Timesheets.Adhoc_Code_3, dbo_Valid_Timesheets.Adhoc_Description_3, dbo_Valid_Timesheets.Adhoc_Pay_Amount_3, dbo_Valid_Timesheets.Timesheet_Number
FROM dbo_Valid_Timesheets
WHERE (((dbo_Valid_Timesheets.Adhoc_Pay_Amount_3)<>0));

UNION ALL SELECT dbo_EE_Payment_History.Employer_Ref, dbo_EE_Payment_History.Personnel_Ref, dbo_Payslip_Static_Data.Department, dbo_EE_Payment_History.Tax_Year, dbo_EE_Payment_History.Tax_Period, dbo_EE_Payment_History.Tax_Session, dbo_EE_Payment_History.Payment_Ref, dbo_EE_Payment_History.Type, Val([Payment_Value]) AS [Value], "" AS Timesheet
FROM dbo_EE_Payment_History INNER JOIN dbo_Payslip_Static_Data ON (dbo_EE_Payment_History.Tax_Session = dbo_Payslip_Static_Data.Session_Number) AND (dbo_EE_Payment_History.Tax_Period = dbo_Payslip_Static_Data.Period_Number) AND (dbo_EE_Payment_History.Tax_Year = dbo_Payslip_Static_Data.Tax_Year) AND (dbo_EE_Payment_History.Personnel_Ref = dbo_Payslip_Static_Data.Personnel_Ref) AND (dbo_EE_Payment_History.Employer_Ref = dbo_Payslip_Static_Data.Employer_Ref)
WHERE (((dbo_EE_Payment_History.Tax_Year)=[Forms]![Misc]![year]) AND ((dbo_EE_Payment_History.Tax_Period)=[Forms]![Misc]![period]) AND ((dbo_EE_Payment_History.Tax_Session)=[Forms]![Misc]![session]) AND ((dbo_EE_Payment_History.Payment_Ref)=777));

UNION ALL SELECT dbo_EE_Payments.Employer_Ref, dbo_EE_Payments.Personnel_Ref, dbo_Payslip_Static_Data.Department, [Forms]![Misc]![year] AS Tax_Year, [Forms]![Misc]![period] AS Tax_Period, [Forms]![Misc]![session] AS Tax_Session, dbo_EE_Payments.Payment_Ref, dbo_EE_Payments.X_Type, Val([Calculated_Value]) AS [Value], "" AS Timesheet
FROM dbo_EE_Payments INNER JOIN dbo_Payslip_Static_Data ON (dbo_EE_Payments.Personnel_Ref = dbo_Payslip_Static_Data.Personnel_Ref) AND (dbo_EE_Payments.Employer_Ref = dbo_Payslip_Static_Data.Employer_Ref)
WHERE (((dbo_EE_Payments.Payment_Ref)=777));

View 10 Replies View Related

UNION ALL Query

May 19, 2005

OK, so I am UNIONing two tables using UNION ALL. It works fine. The resultant table has 192 records (63 + 129).

If a use just UNION or UNION DISTINCT I get 184 records. I'm pretty sure that is telling me that 8 records (192 - 184) exist in both tables.

How do I query to find out what those 8 records are?? I'm trying to use an INTERSECT in MS Access, but it doesn't want to work. Here is my original query:

select * from qryMOE_Active_All
UNION ALL select * from qryMOE_Closed_All;

Thanks,

Brian

View 3 Replies View Related

Union Query

Sep 26, 2005

I am a basic access user so please forgive my ignorance. I have created a union query of three tables. There is one field from the third table that I would like to have in the final table but this field does not exist in the first table. If I put "none" in the first SELECT line, then it queries correctly but the field name on the table is "Expr1006". If I put "Field 2" or [Field 2] in that same space of the first SELECT line, then it asks me for a parameter value and whatever I enter it fills in all the cells of that field with that value. I just don't know that language very well or even if you can add a new field into the first SELECT table. Thank you for any thoughts

Ex: SELECT [Field 1], [Field 2], "none", [Field 3]
FROm [Table 1]
UNION
SELECT [Field 1], "none", [Field 2], [Field 3]
FROM [Table 2]

View 3 Replies View Related

Union All Query Help

Mar 16, 2006

Hello All,
I need help with an Union All Query. It is ignoring the second select statement. Can anyone see what I am doing wrong?

SELECT
CEPM_PLGR.COST_ELEM_CTGY AS [COST_ELEM_CTGY]
, CEPM_PLGR.PROJ_ELEM_ID AS [PROJ_ELEM_ID]
, CEPM_PLGR.COST_ELEM AS [COST_ELEM]
, CEPM_PLGR.SUM_UNIT AS [SUM_UNIT]
, CEPM_PLGR.PRD AS [PRD]
, CEPM_PLGR.CUR_BUD AS [CUR_BUD]
, CEPM_PLGR.PRD_BUD AS [PRD_BUD]
, CEPM_PLGR.CURRENT_ACT AS [CURRENT_ACT]
, CEPM_PLGR.PERIOD_ACT AS [PERIOD_ACT]
, CSIOWNER_PELM.PROJ_ELEM_DESC AS [PROJ_ELEM_DESC]
, CSIOWNER_PELM.PROJ_ELEM_MGR AS [PROJ_ELEM_MGR]
, CSIOWNER_PELM.PROJ_ELEM_TYPE AS [PROJ_ELEM_TYPE]
, NULL AS [COMMIT GA]
, CSIOWNER_PELM.COST_STAT AS [COST_STAT]
, CSIOWNER_PELM.PROJ_NBR AS [PROJ_NBR]
,NULL AS [COMMIT $]
FROM
CEPM_PLGR INNER JOIN CSIOWNER_PELM ON CEPM_PLGR.PROJ_ELEM_ID = CSIOWNER_PELM.PROJ_ELEM_ID
WHERE
((CSIOWNER_PELM.PROJ_TYPE)<>"T&M" And (CSIOWNER_PELM.PROJ_TYPE)<>"T7M") AND ((CSIOWNER_PELM.COST_MODE)="D")
AND ((CEPM_PLGR.PROJ_ELEM_ID)<>" ")
UNION ALL SELECT
NULL AS [COST_ELEM_CTGY]
, NULL AS [PROJ_ELEM_ID]
, NULL AS [COST_ELEM]
, NULL AS [SUM_UNIT]
, NULL AS [PRD]
, NULL AS [CUR_BUD]
, NULL AS [PRD_BUD]
, NULL AS [CURRENT_ACT]
, NULL AS [PERIOD_ACT]
, NULL AS [PROJ_ELEM_DESC]
, NULL AS [PROJ_ELEM_MGR]
, NULL AS [PROJ_ELEM_TYPE]
, (IIf( [PROJECT ID] Like "N0160*" And "N8100*" And "N9004*"
,(NZ([COMMIT $],0))
,(NZ([COMMIT GA $],0)))) AS [COMMIT GA]
, NULL AS [COST_STAT]
, NULL AS [PROJ_NBR]
, [PURCHASE_COMMITMENTS_FINAL].[COMMIT $] AS [COMMIT $]
FROM
[PURCHASE_COMMITMENTS_FINAL]
WHERE [PURCHASE_COMMITMENTS_FINAL].[PROJECT ID]
IN
(SELECT CEPM_PLGR.PROJ_ELEM_ID AS [PROJ_ELEM_ID]
FROM
CEPM_PLGR INNER JOIN CSIOWNER_PELM ON CEPM_PLGR.PROJ_ELEM_ID = CSIOWNER_PELM.PROJ_ELEM_ID
WHERE
((CSIOWNER_PELM.PROJ_TYPE)<>"T&M" And (CSIOWNER_PELM.PROJ_TYPE)<>"T7M") AND ((CSIOWNER_PELM.COST_MODE)="D")
AND ((CEPM_PLGR.PROJ_ELEM_ID)<>" ")) AND (([PURCHASE_COMMITMENTS_FINAL].[PROJECT ID]) <> " ");

I think it is my where clause IN function. But I do not know how to fix it. any help would be great!!!!
Thanks in advanced, Kerrie

View 2 Replies View Related

Union Query

Aug 3, 2006

Okay, people. I am getting married in a few days and my mind is on other things. Consequently, I can't get my head around this one.

I have two queries, Query1 and Query2. Both have a different number of fields but they have the field "IA Code" in common.

I want to create a new query containing all rows from Query1 and all rows from Query2. Where the [IA Code] matches, I'd like the information to be displayed in one row.

I think I need to use Union somewhere along the lines, but I can't work it out.

Any pointers/syntax greatly appreciated.

View 1 Replies View Related

Union Query Help Please

Jan 25, 2007

I have 2 tables with employee details in it. There is no natural link between the 2. I wish to write a query that will sum up the total pay for both tables.

I've had a look through the forum and it seems that a Union query is probably best.

I haven't worked with Unions before, so I did 2 sub queries to total the pay in both table and then union the 2 queries. I did this because there are some date parameters that I query each table by so I do this in the sub queries.

This works but I get 2 outputs in the result, the total pay from each table. I wanted to have just one output, which is the sum of all pay.

Can anyone help please.

SQL:
SELECT QrySub_TotalPay1.TotalPay 'sub query that sums up table 1
FROM QrySub_TotalPay1
UNION SELECT QrySub_TotalPay2.TotalPay 'sub query that sums up table 2
FROM QrySub_TotalPay2;

TIA.

View 3 Replies View Related

Union Query Help

Apr 24, 2007

I have 2 tables and I m trying to get sum of qty for each product
I tried union qurey following way but doesn't work.

Product_Master table has primary key set up on productcode. I need to pick up OpeningBal along with ProductName and ProductCode from this table.

T_PurInvFoot table contains multiple records of the similar ProductCode. I want to make sum of these PurQty data and add it with OpeningBal data from Product_master table and present it in one line.

The avalable quanities are in 2 diff. tables are here.

Product_Master.OpeningBal=5
(1 Record)

T_PurInvFoot.PurQty =4
T_PurInvFoot.PurQty =6
(2 Records)

So total it should be 15 when it produce records. But it show only 10 records from below query.

SELECT Product_Master.ProductCode, Product_Master.ProductName,Sum(Product_Master.Open ingBal) as Stock
From Product_Master INNER JOIN T_PurInvFoot ON T_PurInvFoot.ProductCode=Product_Master.ProductCod e
Group By Product_Master.ProductCode,Product_Master.ProductN ame

UNION Select T_PurInvFoot.ProductCode, T_PurInvFoot.ProductName, sum(T_PurInvFoot.PurQty) as Stock
From T_PurInvFoot INNER JOIN Product_Master ON T_PurInvFoot.ProductCode=Product_Master.ProductCod e
Group By T_PurInvFoot.ProductCode,T_PurInvFoot.ProductName
ORDER BY Product_Master.ProductCode;

Can somebody advice me how to do it.

I need to add 3rd table here in future to get sum of the qty of the similar ProductCode so how to the query would be?

One more thing, can we do it in VBA and set the RecordSource to a form or report ?

With kind regards,
Ashfaque

View 1 Replies View Related

Union Query??

Oct 11, 2007

Hello All,

What I am trying to do is if the field (CAR) or (PAR) or (Incident) is checked in this table (Inventory Worksheet) then show it. I not sure how to use the union query to accomplish this.

Any Ideas?

Thanks,

View 5 Replies View Related

UNION Query

Oct 12, 2007

I have two tables with data and I want to join the data together for a report.

Example:

SELECT tbl1.a tbl1.b tbl1.c tbl1.d
FROM tbl1
UNION SELECT tbl2.a tbl2.b tbl2.c
FROM tbl2;

Currently I can't join them b/c the column counts aren't the same.
If table1 has more columns than table2 can I join them by indicating some kind of phantom column 'd' for table2 to be joined to column 'd' of table1?

View 3 Replies View Related

Union Query

Dec 13, 2007

Will you help me built a union query ? I have 2 queries, qryinput and qryoutput.Out of these query i have a third query called qryDiff substracting these
queries. However qryDiff does not show all the goods sold, only those goods that are substracted.Therefore i want to build an union query but somehow i cannot do it. Will you help ?

My first query, qryinput is :
SELECT [order details].ProductID, Sum([order details].Quantity) AS Sum1, orders.orderid
FROM (orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID) INNER JOIN products ON [order details].ProductID = products.Productid
GROUP BY [order details].ProductID, orders.orderid;
My second query, qryoutput is :

SELECT [order details].ProductID, orders.orderid, [order details].Quantity AS Sum2
FROM ((orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID) INNER JOIN Customers ON orders.customerid = Customers.Customerid) INNER JOIN products ON [order details].ProductID = products.Productid;

My thirs query, qryDiff is :

SELECT qryProducts.ProductID, Sum(qryInput.Sum1) AS imported, Sum(qryOutput.Sum2) AS exported
FROM (qryProducts LEFT JOIN qryInput ON qryProducts.ProductID = qryInput.ProductID) LEFT JOIN qryOutput ON qryProducts.ProductID = qryOutput.ProductID
GROUP BY qryProducts.ProductID;

Now i want to convert the query qryDiff into an union query, but i cannot do it.I somehow managed to build a simple query showing all the products:
SELECT ProductID
FROM qryInput
UNION SELECT ProductID
FROM qryOutput;
This query shows the productsid indeed, but i cannot add the other items form the qryinput and qryoutput as the sum etc.
I also i cannot convert my query qryDiff into an uinion query, with fields for the imported and the exported sums and also for the product names.
Where is my error and now could i achieve my aim? My aim is that in the query qryDiff to show all the products, and not only the products sold.


I will be very grateful for any comments

View 6 Replies View Related

Union Query

Dec 30, 2007

I have 2 tables, Employees and Customers. Each table has a column called active.

How can I make a union query that will return all active employees and customers?

View 1 Replies View Related

Union Query ... Help Me

Mar 23, 2008

Hello friends

How are you

Please I need help in Union Queries
what does this code mean
"SELECT [Query_buy] ,Type.[Query_buy].Sum0 ,no AS InQuin , "Return" as Description From [Query_buy]"

I need to make combined report shows the reteurnd items.
I hope that my words are enough clear

Thank you all

View 1 Replies View Related







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