Use a tables field as query criteria

SteveGr

Registered User.
Local time
Today, 14:47
Joined
Aug 2, 2002
Messages
65
I want to use the data (1 field, but all rows of data) in my my table to be the citeria of a new query.

While keeping the field data in the same order in my new query as it is in the table.

Thanks, Stevegr
 
Can you be more specific when you say "join the two tables?

I have added both tables to the query and it gives me an error. If I delete one of the tables, then I don't get the error. I am not sure if my tables need to have a relationship or not to get this query right.
 
This is the code that creates a make-table query:

SELECT DISTINCTROW TOP 10 tblPress.PressNumber, [DelayCode] & [DelaySubCode] AS Delay, tblDelay.PrimaryDesc, Sum(tblSummary.DelayHrs) AS SumOfDelayHrs, Count(tblSummary.DelayHrs) AS CountOfDelayHrs, [Forms]![frmTopTenDelays]![txtStartDateMnth].[Value] AS [Start Date], [forms]![frmTopTenDelays]![txtEndDateMnth].[Value] AS [End Date], [Forms]![frmTopTenDelays]![txtOperationMode] AS [OP Mode] INTO tblTopTenDelays951sg
FROM tblPress INNER JOIN (tblJob INNER JOIN (tblOperation INNER JOIN (tblLocation INNER JOIN (tblDelay INNER JOIN tblSummary ON tblDelay.TypeID = tblSummary.DelayCodeID) ON tblLocation.LocationID = tblSummary.LocationCodeID) ON tblOperation.OperationID = tblSummary.OpCodeID) ON tblJob.FormID = tblSummary.Form) ON tblPress.PressID = tblSummary.PressID
WHERE (((tblSummary.Date) Between [Forms]![frmTopTenDelays]![txtStartDateMnth] And [Forms]![frmTopTenDelays]![txtEndDateMnth]) AND ((tblSummary.OpCodeID)=[Forms]![frmTopTenDelays]![cboOperation]))
GROUP BY tblPress.PressNumber, [DelayCode] & [DelaySubCode], tblDelay.PrimaryDesc, [Forms]![frmTopTenDelays]![txtStartDateMnth].[Value], [forms]![frmTopTenDelays]![txtEndDateMnth].[Value], tblPress.PressID
HAVING (((tblPress.PressID)=1))
ORDER BY Sum(tblSummary.DelayHrs) DESC;

Now what I need is to capture the Delays from the table and run a new query for a different timeframe using the Delays as criteria.

When I add the tblSummary to the query, I get a Type mismatch error
 
here is a jpeg of my query.

I would like to use all of the data under the delay field to use as my new criteria
 

Attachments

  • delay.jpg
    delay.jpg
    36 KB · Views: 180
Basically I want to use data in my maketable query (Field name: "Delays") as new criteria for a another query.

How do I use the field data "delays" as query criteria?

Under the field "Delays" there are ten numbers that are queried by the most hours for a date range, What I want to do is use those :Delay" numbers and see how many hours we had for a different date range, like last month.
 

Users who are viewing this thread

Back
Top Bottom