Queries :: Multi-Field Union Query (Joining Questions And Pictures Into One Report)
Apr 5, 2013
I have two tables containing (let's say for simplicity) questions and attachments (pictures). I am trying to perform a union query to join all the questions and pictures into one report, but it won't let me union the attachment because 'the multi-valued field 'TableA.Pictures' cannot be used in a union query'.
I have searched and searched for a solution (and got kind of close) but i still can't get it to work. The best I can do is union everything like below, which gives all the questions as desired, but says #Error in the pictures column:
SELECT TableA.*
FROM TableA
Union
SELECT TableB.*
FROM TableB;
(Note tables A and B have the same structure, several yes/no and open text questions as well as one attachment field. )
View Replies
ADVERTISEMENT
May 14, 2013
I have got a db and that has 10+ ref tables, and i need to show everything from those tables in one, and these tables includes Attachment field. I have tried union but did not work.
How can i achieve this?
View 4 Replies
View Related
Sep 14, 2004
is it possible to join these two queries together, so that the 2nd query appears at the bottom of the first?
Code:SELECT OEEModelMCTotals.Machine, OEEModelMCTotals.EventCode, OEEModelMCTotals.CodeDescription, OEEModelMCTotals.SumOfTotalTime, OEEModelMCTotals.Occur, OEEModelMCTotals.PlannedTime, [OEEModelMCTotals]![SumOfTotalTime]/[OEEModelMCTotals]![PlannedTime] AS [%Schedule], [OEEModelMCTotals]![SumOfTotalTime]/[OEEModelMCTotals]![Occur] AS Avg, OEEModelMCTotals.Output, OEEModelMCTotals.Throughput, OEEModelMCTotals.ValueAddedimeFROM OEEModelMCTotalsWHERE (((OEEModelMCTotals.EventCode) Not Like "n204" And (OEEModelMCTotals.EventCode)<>"n301" And (OEEModelMCTotals.EventCode)<>"n303" And (OEEModelMCTotals.EventCode)<>"x104" And (OEEModelMCTotals.EventCode)<>"x117"));
and
Code:SELECT OEEModelOtherTotals.EventCode, OEEModelOtherTotals.CodeDescription, OEEModelOtherTotals.Machine, Sum(OEEModelOtherTotals.TotalTime) AS SumOfTotalTime, Sum(OEEModelOtherTotals.Occur) AS SumOfOccurFROM OEEModelOtherTotalsGROUP BY OEEModelOtherTotals.EventCode, OEEModelOtherTotals.CodeDescription, OEEModelOtherTotals.Machine;
i have attached a spreadsheet with the outcome i am after....i dont want it in excel but have used this for my demonstration.
you will see at the bottom of the sheet i have highlighted the info added in blue.
can this be achieved ?
if so how please.
cheers
Andy
View 1 Replies
View Related
Jan 5, 2005
(I know I posted this question before, but I fear it may have gotten lost in a thread so I am starting a new one)
I have created a multi-field pkey with the ModelDescription and VersionNumber fields. I did it the way that didn't require code as I could not find any online and am not versed enough in VB to do it on my own. I just highlighted both the fields and pressed the "Key" button.
My question is linking the tables. Should I just join them via the ModelDescription field? It won't let me join on both fields. Is it going to matter which field (ModelDescription vs. VersionNumber) I use to join the tables? I've never run into the need to have a multi-field pkey before.
View 1 Replies
View Related
May 7, 2014
I have a database that has over 20 tables in it and am using Access 2000. Unfortunately I cannot change the structure as it performs specific functions, so I am stuck with it.
I have created a Union Query from these tables yaking data from 5 fields using the Serial Number entered by the user.
SELECT[Workstation].UnitPart,PropertyTag,UnitSerial,Date,Technician
FROM[Workstation]
WHERE((([Workstation].UnitSerial)=[Enter Serial No.];
UNION
SELECT[LAPTOP].UnitPart,PropertyTag,UnitSerial,Date,Technician
[Code] ....
I use a bar code scanner to scan the serial number, and it goes through the tables and returns the results along with the other specified fields.
I would like to scan up to 16 or more different serial numbers and have it return the results. Perhaps scan the first 16 serial numbers, then run the query? Is that possible. The serial numbers are unique and will return a combination of laptops, printers, monitors, etc...
I have created a report from the above union query and it works perfectly with only one serial number entered.
View 14 Replies
View Related
Oct 1, 2013
I have a Union Query (that works perfectly fine) with the following code:
Code:
SELECT * FROM sbqryUseBattery
UNION
SELECT * FROM sbqryUseBeltsDeck;
UNION
SELECT * FROM sbqryUseBeltsHydro;
UNION
SELECT * FROM sbqryUseBeltsPTO;
UNION
SELECT * FROM sbqryUseFiltersAir
UNION
SELECT * FROM sbqryUseFiltersFuel
UNION SELECT * FROM sbqryUseFiltersOil;
I am using this information on a Report.
The problem is that the Report shows the data in random order. Is there a way to filter either the Union Query or the Report?
View 14 Replies
View Related
Dec 11, 2013
Is there a way to hide a field in a union query? I need to keep the field in the SQL statement because I need to order by it. The field is "Rank," but I don't want it showing up.
View 3 Replies
View Related
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
May 22, 2013
Access 2010. I've had to learn it at work because our DBA was let go and I was the only one willing to give it a go. Read a book or two and picked up some stuff on the internet.
Here's my problem:
I have a simple table -Employee with 4 fields. FirstName, LastName, Office and JobTitle. I have form called Form1 that has 3 control fields cboJobTitle (a combo box that is populated by a query that finds all the unique values of that field in the Employee table), cboOffice (same as above) and txtName (a text box to allow user input) that are used as the criteria for a multi-field query triggered by a button at the bottom of the form. The idea being that you could do a search using this form to find all the employees in one office or all the accountants in one office, or any other combination.
The main search query has the following criteria for each field -
Like [forms]![Form1]![cboOffice] & "*"
Like [forms]![Form1]![cboJobTitle] & "*"
Like [forms]![Form1]![txtName] & "*"
It works great...until I enter a record where one of those fields may be null, such as if I leave the JobTitle blank.
If I have two employees in an office in one city and then do a search for all the employees in that office, it only returns one record and ignores the one that has the null value in the JobTitle field.
View 14 Replies
View Related
May 16, 2013
On [Form1] I have a Multi-Select Listbox[List1] which shows Job Numbers [WBS] (The job numbers displaying are a result of a separate query filtered by the Fiscal Year combobox). When I click [CMD1] I want [Query1] results to only be selected [WBS] from the form.What is the best way to code this? I'm a beginner when it comes to VBA.
View 12 Replies
View Related
Apr 30, 2014
I'm new to access. Basically I've put this formula in a field within my query(Query A):
PERIOD: [YEAR] & "-" & [Month Number]
And I want to use this newly created field "Period" to join another table (Table A) without having to create another query.
PERIOD(Query A) -> PERIOD(Table A) = Month Name (Table A)
I need the month Name from Table A but because Period(Query A) is a formula I created, I don't know any way of joining it to Table A without creating another query. Is there another way...
View 5 Replies
View Related
Oct 22, 2004
I'll ask in stages:
Can the results of a Union query show up on a report?
My expected results would be something like this.
SumofPT SumofOT SumofST Range
75 80 80 5-Day
120 14 Day
175 120 30 Day
Or am I going about this the wrong way.
I have 5 queries named the different ranges
I prompt for a sum total for a given date range
Individually they work.
The Union Query prompts me correctly. That's as far as I
have gotten.
View 3 Replies
View Related
Aug 6, 2007
Morning Everyone,
I'm currently working on a database that will store Employee Names and their Hours Worked for bookkeeping purposes. The form we have composed currently takes information on a Job to Job basis (i.e., 1 sheet per job) but has several text input fields for the various employees who may have worked on that job (i.e., EmployeeNameA, EmployeeNameB, etc.). The problem lies in our report. Since we have to report on an employee basis rather than a job basis our report requires more complex code.
Through browsing several forums and doing a lot of googling, I learned that the best way to report several fields is to run a union query and compile the data. I did, and now all the EmployeeNameA's B's and C's are simply "Employee" under a new query titled "Employee Query".
I've hit a brick wall since I have no idea how to make the report produce one employee's name alphabetically from that query, then subsequently report all his hours worked for each day of a pay-period week; then list the next employee's name, then all his data, etc. I have the dates set up fine, and the employee union query includes the hours worked and everything else that needed to be compiled, but names refuse to show up when I try to DLookup the union query. I may not need to do a Dlookup, I may be way off. I need some help!
Thanks in advance and feel free to ask any questions!
View 10 Replies
View Related
Sep 16, 2013
So i have a union query pulling together about 3,000 records from other queries.
I arranged all the counts and data I need to fit onto one page, but the report is copying that page (minus the header) for each record in the union query. I'd much prefer a one page report rather than a 3,000 page report.
Why does it do that? All I want is a one page report, how can I make that happen?
View 3 Replies
View Related
Apr 24, 2015
I need to create a census report from the employees we serve and their dependents, by company. I have a union query of the Employees table and Dependents table to put them all on one list, then a form where you can type the name of the company you need, with a button that opens the report. This works great, except for the fact that sometimes we don't need the dependents; if a company has over 100 Full-Time employees, we only need the employees. I've added a check box ([IncDep]) on the form, asking the user if they want to include the dependents, but I don't know how to get this to filter the report. I have a Relationship field on the tables that specifies an employee as a "Subscriber", so I'd like to filter the report where [Relationship] = "Subscriber" but I don't know how to do this. The union query specifies both Employees.Relationship and Dependents.Relationship to the text box [Relationship], but when I do something like
Dim stDocName As String
If Me!IncDep.Value = False Then
stDocName = "Census"
DoCmd.OpenReport stDocName, acViewReport, , "[Relationship]='" & "Subscriber" & "'"
Else
stDocName = "Census"
DoCmd.OpenReport stDocName, acViewReport
End If
View 3 Replies
View Related
Mar 9, 2013
I know that multivalue fields are not the best to use, but I have a simple database that they work fine in. My question is this: Is there a way to show the entire list of choices in the multivalue field on a report? Not just the ones selected, but all of them, whether checked or not? The multivalue field has a list of names and the user selects each name if they repond to a incident (fire, car accident, etc.). My report would show the entire list and count number of responses by each name during a date range. I want to show all of them on the report, with those not selected showing "0".
View 3 Replies
View Related
May 20, 2005
I have a front end that is connected to three back end files. The front end is on my local computer while the back end files are on a network drive.
There are a lot of calculations that go into the queries and intermediate queries. For a report, I have based it on a UNION query.
But when trying to design the report it takes about 45 seconds just to do any one thing, e.g.;
- Add Groupings
- Add Grouping Headers//Footer, sorting option
- Add bound textbox
:eek:
Needless to say this is very annoying.
:mad:
The union query itself runs fine (takes about 15 seconds to run) and returns about 12,000 Rows. The union query looks like this (I changed the field names to make it read easier, hopefully);
SELECT a1, a2, a3, a4, a5
FROM qry_A;
UNION SELECT ALL a1, b2 AS a2, b3 AS a3, a4, a5
FROM qry_B;
UNION SELECT ALL a1, c2 AS a2, c3 AS a3, a4, a5
FROM qry_C;
UNION SELECT ALL a1, d2 AS a2, a3, a4, a5
FROM qry_D;
UNION SELECT ALL a1, e2 AS a2, a3, a4, a5
FROM qry_E;
UNION SELECT ALL a1, f2AS a2, tblG.f3 AS a3, tblG.f4 AS a4, a5
FROM qry_F;
One solution I came across when searching the forums was to use an Append Query to append the query results to a table and base my report on that. This does indeed fix the problem.
But what I was wondering if it was is my query design that is causing it to be slow or is it just the fact that I am returning 12,000 rows?
:confused:
In case it matters, I wanted to mention that I can’t use the report wizard to create the report. When I select the union query, the fields will be showed for awhile then they just disappear. That in and of itself doesn’t cause any trouble since I am creating the report using the design view and not the wizard.
View 7 Replies
View Related
Oct 11, 2013
After putting in fields there were checkboxes into a Union Query, they now show up as -1s and 0s. Is a -1 a blank, and a 0 checked?
View 1 Replies
View Related
Sep 12, 2013
I'm having a small problem where Access returns a "Query too complex" error when I try to run a Union query of the form:
Code:
SELECT CourseNumber, CourseTitle, [Date], TotalScore, "Two (2) zero visibility dives?" AS [Question], CountZeroVisibility AS [NegativeResponses]
FROM qryScore
UNION ALL
SELECT CourseNumber, CourseTitle, [Date], TotalScore, "One (1) night dive?" AS [Question], CountNightDive AS [NegativeResponses]
FROM qryScore
UNION ALL
...etc
With more than 13 unions.
View 13 Replies
View Related
Dec 18, 2014
I have two basic lists of employee names, ID's, phone numbers etc, with one field containing an attachment with a picture of their ID. I don't want to permanently combine these two lists of employees, as they work in different departments, but for certain events I need to be able to print a report with a list of all their names, ID numbers, and corresponding ID photos.
I tried to make a UNION query, but can't do it with the attachment field. If I leave that field out, it's no problem. To simplify, I have been doing a test run as follows, with just the name field and photo field (field 1).
SELECT [Starting Gate employees].[Employee name], [Starting Gate employees].Field2
FROM [Starting Gate employees]
UNION
SELECT [Farrier employees].[Employee name], [Farrier employees].Field2
FROM [Farrier employees];
View 2 Replies
View Related
Aug 5, 2013
I have a Union Query which the result was like this:
Date Cash_In Cash_Out
08/06/2013 100.00
08/06/2013 25.00
08/06/2013 50.00
08/06/2013 20.00
Note: The Date Field comes from two different tables. Original field names are Cash_In_Date and Cash_Out_Date.
View 5 Replies
View Related
Jun 3, 2015
I have three queries that make a training list based on a person's role, team, and ad-hoc exceptions. The personnelID field is filtered by a listbox on a form. Each of these work great on their own (nice!). Now I want to combine them. I made the below union query that works... however when it is run, I am prompted to enter the personnelID again. This prompt only happens once. Do I need to incorporate a qhere statement somewhere, even though each of the individual queries have them already?
SELECT First_Name, Last_Name, TrainingTitle, PersonnelID
FROM qryPersonnelTrainingByRole
UNION ALL
SELECT First_Name, Last_Name, TrainingTitle, PersonnelID
FROM qryPersonnelTrainingByTeam
UNION ALL SELECT First_Name, Last_Name, TrainingTitle, PersonnelID
FROM qryPersonnelTrainingByAdHocPersonnel;
The where statement of potential use:
Code:
WHERE (((tblPersonnel.PersonnelID)=[Forms]![frmMain]![lbxPersonnel]));
View 6 Replies
View Related
May 7, 2014
Im trying to join two queries as I am unable to use just a single query but I cant use a union query as the query fields aren't exactly the same.
Both queries have a PO_Detail field as every PO has a PO_Detail number assigned to it. 3 of the same records are in both query results but one query is missing the other two results.
If I create a join between the two queries based on this field I don't get all the results. Unfortunately I cant upload the database as it has sensitive data which would take me ages to clear out but I can show a picture of the results.
View 10 Replies
View Related
Oct 28, 2013
Am trying many times in UNION query but its not working because there is different field names and only some fields are matched. So I need to both query's are combine in 1 query.
They Quays details:
1.Customer Credit Transaction1
2.Customer Credit Transaction2
Above both queries are already combined in UNION query as (Customer Credit Transaction Final) its not a problem.So now I need to do combine the above Union query Customer Credit Transaction Final & ReceiptformQry.
The both query details:
Customer Credit Transaction Final
SELECT BillBook1.TID, BillBook1.BILLNo, BillBook1.BILLDate, BillBook1.Customer, BillBook1.BillMode, [BillBook1 Vat Details].[TOTAL Rs] AS [CC Amount]
FROM BillBook1 INNER JOIN [BillBook1 Vat Details] ON BillBook1.TID = [BillBook1 Vat Details].TID
WHERE (((BillBook1.BillMode)="Credit"));
UNION ALL
[code]...
Above fields are need to merge in Union query or otherwise. and remaining fields are needed to show separately.
View 6 Replies
View Related
Mar 8, 2006
Hi,
I have a query that I build using VBA based on some user input. One of the fields I pull out is a hyperlink to particular files on our local network, so the user can click the link and open the relevant file. My problem is that if the SELECT statement contains one (or more) UNIONs the hyperlinks no longer work. The query returns all the fields but the hyperlink field is just text of the form "display_text#link_address#".
I am using MS Access 2000. The UNION statements are required so I can search for multiple keywords in various fields within the table.
An example of the SQL query I generate is:
SELECT DocRef, DocTitle, DocAbstract, DocLink, DocAuthor, DocDate FROM TechDocs
WHERE DocType IN ('TechRep', 'Misc')
AND DocAbstract LIKE ('*drug*')
UNION
SELECT DocRef, DocTitle, DocAbstract, DocLink, DocAuthor, DocDate FROM TechDocs
WHERE DocType IN ('TechRep', 'Misc')
AND DocAbstract LIKE ('*release*');
If I do the query a different way (when I am searching for phrases, not keywords) the hyperlinks work fine. As you can imagine this is very frustrating! I have read that Access 2000 has some problems with UNIONs where it has to order the individual SELECT results before the union or something, but I can't work it out. :confused:
Any help is much appreciated.
View 1 Replies
View Related
Feb 16, 2007
I have a table called LLD Import Table with the following fields in it.
FileNumber, LandDescription, Qtr1, Sec1, Qtr2, Sec2, Qtr3, Sec3, Qtr4, Sec4, Qtr5, Sec5
Data Example:
123456, T43 R2 W5M, S, 6
123457, T43 R1 W5M, SE, 18, SW, 17
123456, T43 R1 W5M, E, 19, E, 30, SW, 29, E, 31, NE, 18
What I have done so far is to create a Union query to create a new record with the file and land description repeating for each row where there is quarter and section data with the following code:
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec1 AS Section, [LLD Import Table].Qtr1 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec1) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec2 AS Section, [LLD Import Table].Qtr2 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec2) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec3 AS Section, [LLD Import Table].Qtr3 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec3) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec4 AS Section, [LLD Import Table].Qtr4 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec4) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec5 AS Section, [LLD Import Table].Qtr5 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec5) Is Not Null));
To give this result:
FileNumber, LandDescription, Quarter, Section
123456, T 43 R 1 W5M, NE, 18
123456, T 43 R 1 W5M, E, 19
123456, T 43 R 1 W5M, SW, 29
123456, T 43 R 1 W5M, E, 30
123456, T 43 R 1 W5M, E, 31
123456, T 43 R 2 W5M, S, 6
123457, T 43 R 1 W5M, SW, 17
123457, T 43 R 1 W5M, SE, 18
However the number of Quarters and Sections under a file changes, so next time I my table could have fields up to Qtr20 and Sec20 What I’d like to do is to create a function that will automatically change the # behind the field names (to replace the * in the example below) so that I don’t have to rewrite the Union Query each time. I’ve seen some code examples that can change the value, but don’t quite understand them enough to write one.
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec* AS Section, [LLD Import Table].Qtr* AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec*) Is Not Null));
Your help would be GREATLY appreciated!
View 1 Replies
View Related