Union Queries And Selecting Fieldnames With Criteria

Oct 18, 2006

I am trying to combine fields (different columns) into one field. However I am trying to have a criteria for the fieldname. For example I wish only to combine the columns that contain the text 2003 (ie [Value 2003],[Price 2003]). I have tried to use wildcards in SQl ie select * from [query] where * = %2003. I must be missing something because I can't seem to work it out. It must be simple. I have also tried several ways through the design grid with wildcards in expressions. I also don't want to union the columns by using the exact names ie [Value 2003]& [Price 2003] because additional columns may be added.

Any help, extremely appreciated, I have wasted a whole day with this.

Deesy.

View Replies


ADVERTISEMENT

Automate Changes Of Fieldnames In Tables/queries

Jan 31, 2008

I have a reasonable large dbase with some 12 tables and some 40 Queries.
In three of the tables, there are fields with dubious names like AA1, CD-3, 227, etc.
I want to change these field names to some more appropriate names like : Testblok , Cspeler, Jaarnummer, etc, etc.

In doing so, I will have to go thru each and every Query ( and at a later stage forms/reports) to change the fieldnames in that query corresponding to the changes I made in the initial table field name.

Would there be another way of doing this, i.e. is there a routine for changes made in the fieldnames, being “automatically updated in the table bound query.

View 6 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

Input Criteria Into Union Query From A Form

May 31, 2006

Based on information from a earlier thread.... I created a Union query that pulls information from multiple tables and fields.


SELECT AG_B_R1 as Num FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_B_R2 FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_B_R3 FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_B_R4 FROM dbo_ADC_Ag_B_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_m_R1 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_m_R2 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_m_R3 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_m_R4 FROM dbo_ADC_Ag_m_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_e_R1 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_e_R2 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll]
UNION ALL
SELECT AG_e_R3 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll]
UNION ALL SELECT AG_e_R4 FROM dbo_ADC_Ag_e_Res WHERE Rollnmbr=[roll];


And then I created another query to get the STDEV of the above query


SELECT StDev([Num]) AS StDev
FROM Q_cals_ag_bme_STDEV_Union;

The result will be on a subform on my main page. How do I get my form to input the [roll] automatically and requery the subform, showing my result.
Thanks

View 1 Replies View Related

Modules & VBA :: User Input Criteria For Union Query?

Aug 20, 2013

I am trying to get my VBA code to dump a query once the user pushes a button. I have the following code to call up the Excel app.

Code:

Option Compare Database
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long

[code]....

The qry_PP_Errors_Union is a Union query. In this query there is a date field. I would like to be able to to use that date field as a parameter. So I have written this VBA to prompt the user for a Begin Date and an End Date.

Code:
Beep
strBegindatemsg = "Enter the beginning date." & vbCrLf & vbLf
strBegindate = InputBox(Prompt:=strBegindatemsg, Title:="Begin Date")
Beep
strEnddatemsg = "Enter the beginning date." & vbCrLf & vbLf
strEnddate = InputBox(Prompt:=strEnddatemsg, Title:="End Date")

Now the part that I am missing is that I am not sure how to make the "strBegindate" and "strEnddate" the criteria for the union query.

The following is the SQL for my union query.

Code:
SELECT LastName, FirstName, Title, TeamName, WorkOrderNumber, DateCompleted, WorkCode, UICError AS Error, "Update and Internal Correspondence" AS Category FROM qry_PP_UIC_Error
UNION
SELECT LastName, FirstName, Title, TeamName, WorkOrderNumber, DateCompleted, WorkCode, BIDError, "Bids" FROM qry_PP_Bid_Error

[Code] ....

Without the criteria, my code works for dumping everything out into Excel. However, dumping all the data results in a 7 mb Excel file that requires manual deletion of the information that is not pertinent.

View 3 Replies View Related

Selecting Criteria In A Query

Jan 22, 2006

Hi, I'm a complete novice to Access and wonder if anyone can help me with this one please? I have a column in a query that is the output from a barcode scanner called WhenScanned from a table tblScans. The data in the column is in the format of the date and time for example: 20/01/2006 21:30:00 I want to be able to interrogate the data in the query by selecting a range of a date(s) and times for example from 20/01/2006 05:30:00 to 20/01/2006 13:29:00, date and time range from 13:30:00 to 21:29:00, date and time range from 21:30:00 to next day 05:29:00. I can achieve this by typing the required range into the criteria row of the query column in design view e.g. >=#20/01/2006 13:30:00# And <=#20/01/2006 21:29:00# for each range but I want to make it more user friendly so that a user can select type in the appropriate date and select the time range from a drop down list or something without having to edit the query using syntax. Thanks in anticipation.

View 2 Replies View Related

Selecting Query Criteria From A Combo Box.. Please Help!!!

May 17, 2007

Hi all

I am trying to get my head around some of the more advanced “features” of access..

At the minute I am trying to change the criteria of a query from selecting a value from within a combo box.. I believe I have got the syntax correct, but I keep getting no results returned..

I am using:
[forms]![frmMovies]![combo2] as the criteria where frmMovies is the name of the form, and combo2 the name of the combo box.. I have set combo2’s source as the table containing the movie information “tblMovies”
Before you ask I am not trying to setup my own movie store, more apply the theory to a bigger DB that I am working on :-p

Hopefully you can help, as I have now been scouring the forums for 2 days and am getting no where..

Thanks in advance

Noel

View 2 Replies View Related

Selecting Records Based On Multiple Criteria

Jul 10, 2007

hi,

i am querying a single table that contains card numbers and corresponding transaction codes (amongst other things). a single card number can have multiple transaction codes.

i want to select all card numbers that have both 0100 and 0802 transaction codes.

if i use a select query with ="0100" Or "0802"as the criteria, it returns all card numbers that have either 0100 or 0802 transaction types. if i then change the query to crosstab and group by card number, it is clear that some cards have both transaction types.

when i try to change the criteria to ="0100" And "0802" it returns nothing at all.

i'm sure the solution is something really simple - any idea what i'm doing wrong?

View 7 Replies View Related

Print Out With Fieldnames

Feb 11, 2005

Is there an easy way to printout a form in disignview so the fieldnames appear in the inputboxes? I've a form with 11 tabs and on each tab at least 10 input boxes (10x11 = 110 boxes :eek: ) Writing down the names on a printout is NOT effective

Thnx

View 2 Replies View Related

Create FieldNames Using Field Value

Aug 20, 2004

I have a table in an Access 2000 database: [SAP_Survey_Answers] that contains FieldNames: CO_ID, ES_ID,
PKey, QFieldName, QAnswer. The *_ID are ID#, QFieldName lists the questions in a survey, & QAnswer corresponds to the QFieldName and gives the answer given by the customer. Here's the dilema: I need to create a new table with CO_ID, ES_ID as Field Names BUT I also need each question as a new field name. How can this be done? Query? SQL statement? I've been racking my brain on this one. Any help would be greatly appreciated!

View 3 Replies View Related

Queries :: Combining Two Queries Without Union Query

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

Queries :: How To Do Combine Two Different Queries In UNION Query

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

Union Queries

Jul 18, 2006

Hi Everyone.

I need help with union queries. The database that i am working with has union queries within it. I need to added information from a certain table into this query so that i can have a report generate more information when it is run. Please help if anyone knows how to work with union queries, or where i can go to find information on this.


Thank you:confused:

View 1 Replies View Related

The Union Of 2 Queries

Oct 6, 2006

I have a question regarding union queries, for the most part I understand them. You have to have the same amount of fields in both tables/queries, but what I do not know is do both tables/queries need to mimic each other 100%.

For example I have 2 Queries, both match each other identically in terms of fields and the order they are placed. What does not match is that I have one query with a "true" criteria under one field and the other query has a "true" in a seperate field.

When the query is ran I get "The number of colums in the two selected tables or queries of a union query do no match."

What is the purpose of the query, I am needing to combine these 2 queries into 1 for a report. If you need the code just ask and I shall post it.

Thanks ahead of time guys.

View 2 Replies View Related

FieldNames In Subject Line Of SendObject Action In Macro

Aug 6, 2004

I have a Macro setup and SendObject is one of the Actions. It is setup to send an existing report. Is there a way to insert a fieldname from that report into the Subject line of the e-mail that is sent? That would be great, instead of having the same subject line for every e-mail, using the date or something like that. Please let me know. Thanks.

View 3 Replies View Related

Union Problem On Two Queries

Mar 15, 2006

Hi everybody, I have a little problem that I've been trying to solve since last night.

I have two table queries I would like to join.

First one 'query1' is as follows:

TextA TextB
A "a10"
B
C
D
E
F

Second query is:

TextA TextB
A "a14"
A "a10"
B "b23"
C "c28"
D "d43"
D "d42"
D "d41"
E
F "f63"
F "e56"

Now what I want to do is join the two queries together based on TextA so that all the duplicates in query2 are removed e.g. AADDD etc

I tried a union query but its still duplicating the letters.

Secondly (although of lesser importance) I need to get "e56" into E in query2.

Anyone else have any ideas?

Many thanks

View 7 Replies View Related

Joining 2 Queries - Union I Think

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

Queries :: Union All SQL Totals Sum Of

May 15, 2015

I have two tables, joined together with a Union query, and what I'd like out of it is a Sum of Categories & Sub Categories, based on all days this year. When run on their own, they give me exactly what I need, but when used with UNION ALL, I have duplicate "Sub Category" Entries...

One from one side of the query, and one from the other..Is there anyway this can be put on just the one line?the SQL I'm using is this...

Quote:

SELECT tblTopLines.Category, tblTopLines.SubCategory, Sum(tblTopLines.Credit) AS SumOfCredit, Sum(tblTopLines.Debit) AS SumOfDebit
FROM tblTopLines
WHERE (((tblTopLines.TransDate) Between #1/1/2015# And #12/31/2015#))
GROUP BY tblTopLines.Category, tblTopLines.SubCategory
HAVING (((tblTopLines.Category)="Car"))
UNION ALL
SELECT tblSplits.Category, tblSplits.SubCategory, Sum(tblSplits.Credit) AS SumOfCredit, Sum(tblSplits.Debit) AS SumOfDebit
FROM tblSplits
WHERE (((tblSplits.TransDate) Between #1/1/2015# And #12/31/2015#))
GROUP BY tblSplits.Category, tblSplits.SubCategory
HAVING (((tblSplits.Category)="Car"));

As I said, SQL isn't my thing, but every stone unturned is another feather and all that..

View 9 Replies View Related

Queries :: Checkboxes Becoming -1 And 0 In Union Query?

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

Queries :: Possible To Use SQL OUTER JOIN Or UNION

Jan 9, 2015

I have a table and a query. The first 4 fields of the table correspond to that of the query. The query does not have any other fields, but the table has 26 more fields. Is it possible to use SQL OUTER JOIN or UNION or whatever to append the data of the query to the table or do I have to go with recordsets of VBA?

View 6 Replies View Related

Queries :: Date Range With UNION ALL

May 6, 2015

I used UNION ALL to get results from two queries and I Succeeded.Now I want these results to be in a date range, so I want to enter the "starting date" then the "End Date" to have may results in specific date range.This is the original code out of UNION ALL which is working fine:

SELECT Count(Patient.PatientID) AS CountOfPatientID, Patient.CauseOfAmpLowerLt
FROM Patient
GROUP BY Patient.CauseOfAmpLowerLt
HAVING (((Patient.CauseOfAmpLowerLt) Not Like ""))
UNION ALL SELECT Count(Patient.[PatientID]) AS CountOfPatientID, Patient.[CauseOfAmpLowerRt]
FROM Patient
GROUP BY Patient.[CauseOfAmpLowerRt]
HAVING (((Patient.CauseOfAmpLowerRt) Not Like ""));

And this is what I tried:

SELECT Count(Patient.PatientID) AS CountOfPatientID, Patient.CauseOfAmpLowerLt
FROM Patient
GROUP BY Patient.CauseOfAmpLowerLt
HAVING (((Patient.CauseOfAmpLowerLt) Not Like ""))
UNION ALL SELECT Count(Patient.[PatientID]) AS CountOfPatientID, Patient.[CauseOfAmpLowerRt]
FROM Patient
GROUP BY Patient.[CauseOfAmpLowerRt]
HAVING (((Patient.CauseOfAmpLowerRt) Not Like "") AND (PatientService.[Date of Service]) BETWEEN [Start Date] AND [End Date]);

View 4 Replies View Related

Queries :: Max UNION ALL In Single Query

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

Queries :: Union All Reverting To ID Numbers

Aug 12, 2014

I have created a database for my hobby of being an (American) football official. I have one table of officials and another for matches to track the matches that I have worked. There are 3-7 positions that officials can work in any one match.

I want a query that will tell me which officials I have worked with and in how many matches (in total regardless of position). I have created a union all query to give me a list of officials names each time they appear. Rather than giving me the result as the names it comes back as the ID numbers from the Officials table.

The SQL query is:

SELECT Ref FROM Matches WHERE Ref Is Not Null
UNION ALL
SELECT Umpire FROM Matches WHERE Umpire Is Not Null
UNION ALL
SELECT LineJudge FROM Matches WHERE LineJudge Is Not Null
UNION ALL
SELECT HeadLine FROM Matches WHERE HeadLine Is Not Null
UNION ALL
SELECT BackJudge FROM Matches WHERE BackJudge Is Not Null
UNION ALL
SELECT SideJudge FROM Matches WHERE SideJudge Is Not Null
UNION ALL SELECT FieldJudge FROM Matches WHERE FieldJudge Is Not Null;

The field used in each position is a full name field ([Surname] & ", " & [Name])

View 5 Replies View Related

Queries :: Make A Union Query

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

Queries :: Union (all) Does Not Like Multi-Value Field?

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

Queries :: Union Query - Group By Then Sum

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







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