View Full Version : Using one table as a reference to another


bhpchan
04-07-2003, 01:28 PM
Hi,

I'm new to Access and presently I have two tables. One consists of raw data with 2 columns (Time and Data). The other consists of 3 columns (Type, Start, and Stop).

Start and Stop corresponds to the Time in the first table.

Let's say if I want to know what the maximum value is between "start" and "stop" in the 2nd table. How can I achieve that?

One thing I want to clarity is that if it's @ all possible to CHANGE the start and end as some sort of a REFERENCE to the 2nd table. That will be the most helpful.

Thanks!

The_Doc_Man
04-08-2003, 01:41 PM
As a side note, never pick keywords (Time, for example) as field names. Access goes bonkers over this.

However, your question is a bit vague. To save time, I'm going to answer the question to the best of my ability as I interpret your question. If I'm answering the wrong question, I'm sorry for the fog factor I'm adding.

In general, you can run a query of a query. So, let's say that Start and Stop are actually date (+time) fields.

The difference between the start and stop, as date/time values go, is just [Stop] - [Start]. So to compute the maximum of these values, build a query for which one of the fields reads

Diff1: [Stop] - [Start]

in the Field row. Then, in the Sort row, select "Ascending". From this query, write a second query that says "SELECT FIRST 1 [Diff1] FROM myQueryName."

Alternatively, if you need this value in VBA code, do a DMax on the Diff1 field over the domain represented by the query.