Re: Calculated field question
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Fri, 23 Dec 2005 10:14:44 +0800
In a query, you could use a subquery to get the time from the previous row.
Example of what to type into the Field row in your query:
PriorTime: (SELECT Max(Dupe.EventTime)
FROM tblEvent AS Dupe
WHERE Dupe.EventID = tblEvent.EventID
AND Dupe.EventTime < tblEvent.EventTime)
If your report performs any aggregation that depends on the subquery field,
you are likely to run into a "Multilevel group-by error". In that case, you
would need to use the much slower DMax() instead of the subquery.
Another alternative is to use the events of the report section to store and
retrieve the details:
1. In the General Declarations section of your report's module (top),
declare the variable:
Dim PriorTime As Variant
2. In the Format event of your Event group header, reset it:
PriorTime = Null
3. In the Print event of your Detail section, store the value:
PriorTime = Me.[EventTime]
4. In the Format event of your Detail section, assign the value to the text
box:
Me.[txtPriorTime] = PriorTime
(There is a problem with this approach if the user prints only some pages of
the report, in that the variable may not be initialized properly, but this
would only affect the first record on the page.)
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Neil Grantham" <neil40@xxxxxxxxxxxxxx> wrote in message
news:1135302367.472057.176530@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>I have a table that is a list of results (1st to 10th) for various
> events.
>
> Each line in the table has an event code, so that they get grouped
> correctly on a report (page per event)
>
> Each comptitor has a finishing time recorded.
>
> In my report, I would like to show the time difference from the
> previous competitor.
> I believe the best way is not to store calc's in the table, so how
> would I calculate this in a query?
>
> Thanks and Merry Christmas
> Neil
.
- Follow-Ups:
- Re: Calculated field question
- From: Neil Grantham
- Re: Calculated field question
- References:
- Calculated field question
- From: Neil Grantham
- Calculated field question
- Prev by Date: Calculated field question
- Next by Date: Re: Need help to find most popular records in 2 related Tables
- Previous by thread: Calculated field question
- Next by thread: Re: Calculated field question
- Index(es):
Relevant Pages
|