R
red skelton via AccessMonster.com
Re-Post:
Thanks for the reply,
I see now where I was getting the syntax error, and now the query runs but,
its not pulling the correct numbers. for example, I have an TimeOutOfOR of 9:
00 and the next start OR time of 9:20. While the minute gap should be 20
minutes, the query displays 4 minutes. My next record shows TimeOutOfOR of 11:
00 and the next start OR time of 11:30 where the minute gap should be 30
minutes, the query shows 2 minutes etc. I have included my current query and
the
SQL statement behind the query. Again, I have tried different query
structures but I can seem to make it come out correctly.
MinutesGap: DateDiff("n", Table1.TimeOutOfOR,(SELECT Min(Dupe.[OR Start])
FROM Table1 AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR AND Dupe.[OR#]
= Table1.[OR#]))
SELECT Table1.Name, Table1.Date, Table1.SSN, Table1.[OR#], Table1.Surgeon,
Table1.Procedure, Table1.[UCA Code], Table1.[OR Start], Table1.TimeOutOfOR,
DateDiff("n",[Table1].[TimeOutOfOR],(SELECT Min(Dupe.[OR Start]) FROM Table1
AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR AND Dupe.[OR#] = Table1.
[OR#])) AS MinutesGap
FROM Table1
WHERE (((Table1.Date) Between [Enter Date From] And [Enter Date To:]) AND (
(Table1.[OR#])=[Enter OR#]))
ORDER BY Table1.TimeOutOfOR;
Does anyone have an idea on how to make this query work?
Thanks very much for your time,
Red
Thanks for the reply,
I see now where I was getting the syntax error, and now the query runs but,
its not pulling the correct numbers. for example, I have an TimeOutOfOR of 9:
00 and the next start OR time of 9:20. While the minute gap should be 20
minutes, the query displays 4 minutes. My next record shows TimeOutOfOR of 11:
00 and the next start OR time of 11:30 where the minute gap should be 30
minutes, the query shows 2 minutes etc. I have included my current query and
the
SQL statement behind the query. Again, I have tried different query
structures but I can seem to make it come out correctly.
MinutesGap: DateDiff("n", Table1.TimeOutOfOR,(SELECT Min(Dupe.[OR Start])
FROM Table1 AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR AND Dupe.[OR#]
= Table1.[OR#]))
SELECT Table1.Name, Table1.Date, Table1.SSN, Table1.[OR#], Table1.Surgeon,
Table1.Procedure, Table1.[UCA Code], Table1.[OR Start], Table1.TimeOutOfOR,
DateDiff("n",[Table1].[TimeOutOfOR],(SELECT Min(Dupe.[OR Start]) FROM Table1
AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR AND Dupe.[OR#] = Table1.
[OR#])) AS MinutesGap
FROM Table1
WHERE (((Table1.Date) Between [Enter Date From] And [Enter Date To:]) AND (
(Table1.[OR#])=[Enter OR#]))
ORDER BY Table1.TimeOutOfOR;
Does anyone have an idea on how to make this query work?
Thanks very much for your time,
Red