Forming queries from two separate records on same row

lifeis

Registered User.
Local time
Today, 15:44
Joined
Dec 9, 2010
Messages
10
Hey All,
Unfortunatly I seem to have hit a brick wall with an application I am currently developing. I have tried everything I can think on, but just cant get my head around how to acheive what I need.
Basically, I am using Pass-Through queries to query a remote SQL Server, the application has to create reports on various data from within the SQL Database.
Currently, my code generates two Access tables, which contain around 10 dates/times, each on a separate row. One table contains 10 Start date/times and the other, the 10 corresponding End date/times. I then need to perform various Pass-Through queries to the SQL Server based on the data in these records, for example (in Pseudo Code):
SELECT some value FROM remote SQL Server tables WHERE Date > first record from StartTimes access table AND < first record from EndTimes access table

And so on until the value has been found between each. Then once this is done, I will ultimately merge the Access tables together to arrive at something like:
Start Times End Times Peak Temp
01/01/2011 09.00 02/01/2011 08.00 33
03/01/2011 11.00 04/01/2011 13.00 31 etc etc

My big problem is comes when I have to get the Peak Temp values, I can loop through the records in the Start Times access table, but in order to query the Peak Temp values, I need both the Start Time and the corresponding End Time, which is where I am totally lost.
Any help would be greatly appreciated.
 
Hi lifeis,

How about using a make-table/append query and download/merge those two remote tables into one table into your MDB locally? You can then query that local table instead.
 
Hi penguino29,
Thank you for your reply.
I would do this if it was possible, the problem I have when doing this is that my two tables don't have a unique identifier (or primary key, whatever access calls it), so when I try to merge the tables into one, it assumes each value is related to every other value, so for a table of 13 rows, the resultant combined table has 169 rows.
Am I missing something here? The code I use to create these tables (they are actually queries) is
Code:
.CreateQueryDef("STimes","SELECT * FROM PassSTimes")
And just the same but for 'ETimes'. So would it maybe somehow be possible to adjust the above code to add an AutoNumber or such?
Thanks again for your help.
 

Users who are viewing this thread

Back
Top Bottom