I have been searching high and low for the last three days to this situation. I am a n00b to Access and SQL but feel I've put forth due diligence here.
I can't quite figure out how to link these two queries correctly.
Sorry, some of the stuff is private so I had to just make generic names.Code:SELECT table1.fields1, table1.fields2, table1.fields3 FROM table1 WHERE (((table1.date_time) Between [Start date:] And [End date:]) AND ((table1.line_ID Like [Machine1] or table1.line_ID Like [Machine2]) (SELECT table2.Part_Number, table3.machine, table2.serial_number, table3.date_time, table3.event FROM table2 INNER JOIN table3 ON table2.serial_number = table3.part_number WHERE (((table3.serial_number) Like [SerialNumber]) AND ((table3.event)="EventStart" Or (table3.event)="EventStart")));
So here's the deal... the subquery would return a value from a Serial Number of when an event started and ended. Gives the date and time.
We then take that date and time and use it as inputs for the next query which then pulls a bunch of other data.
I'd like for us to just put in a serial number once, it go find that start and end date, then use that output to execute the next query and it just display the dataset for that serial number between the dates of the inner query.
As of right now, it tells me: "You have written a subquery that can return more than one field without using the EXISTS reserved word in the main query's FROM clause. Revise the SELECT statement of the subquery to request only one field"
Which... I don't want one field. I need the StartEvent date and time and the EndEvent date and time to be used as the Start Time and End Time of the outer query.
I've seen using WHERE value IN but that throws the same error. When I just do WHERE EXISTS
Sorry if any of this is not clear. I got that mountain-of-knowledge situation where I don't really know what to start searching for. I've read a lot of about queries, subqueries, the different expressions, comparisons, and sqlstatements, but there's a nuance I'm just overlooking somewhere.