No. You cannot force the report to go back to the previous record and form
it based on the current record.
You might be able to add a subquery to the query that the report is based
on, to get the value from the next row into the current record. If you want
to give it a shot, this is the kind of thing you would type into the Field
row of your query, assuming:
- a table named "MyTable",
- a primary key field named "MyID",
- the field to return is named "MyField":
SELECT First([MyField]) FROM MyTable AS Dupe
WHERE Dupe.MyID > MyTable.MyID
ORDER BY MyID;
Potential drawbacks:
- It does not work correctly if you sort or filter the report.
- It will probably slow down the report significantly.
- It may end up with a "Multi-level group by not allowed" error.
- Occassionally, one of these subqueries just crashes instead of ever
producing results.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Dial222 said:
The basic idea is to:
- Use a module level variable variable to hold the value
between
records. - Store the value in the Print event of the
section.
- Read the value and assign the formatting in the Format
event of the
section.
1. Open the report's module, and declare a variable in the
General
Declarations section (top of module, with the Option
statements):
Dim mvarLastValue As Variant
2. In the Open event of the report, initialize the
variable:
mvarLastValue = Null
3. In the Print event of the Detail(?) section, assign the
value to
the variable, e.g.:
mvarLastValue = Me.Result
4. In the Format event of the Detail section, set the
formatting you
want, based on the variable, e.g.:
If Me.Result > mvarLastValue Then
Me.Result.BackColor = vbRed
Else
Me.Result.BackColor = vbBlue
End If
Notes:
- If the Result is null or the previous result is Null,
thte
Else
block will execute (giving the blue color in the above
example).
- If the user only prints some pages from the report (e.g.
only page
5), the events will not fire for the intervening pages, so
the first
line printed may not be formatted correctly.
Cheers Allen, will give it a look over in the morrow.
Carl
Hi allen
Go tthis working for the current row, where it is the second
row of the detail section bu tin the case where i need to
format the previous(ie first) because that value is greater I
am unable to roll back to that row for formatting. Is there
any way I can force a retreat event for a single group of
data, since every course represents a group this would allow
me access to the row I need.
Is there any way I can manipulat the report recordset to
moveprev, with a cancel on the current format event?
Cheers again