Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Access Query Table: Show value of previous row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bryn Stevenson - 01 May 2008 11:25 GMT
I have created QueryTable from MainTable showing data sorted by StartDateTime. Is there a formula or way of updating the added column QueryTable.PreviousEndDateTime with the value of QueryTable.EndDateTime from the previous row in the query for each record in the query?

The end result is to show the MainTable data in a form by start date/time order whilst alerting that the previous records end date/time field is different to the current records start date/time field. Records in MainTable may be in any order as it stores times on each job for different people.
KARL DEWEY - 01 May 2008 19:16 GMT
One way is to add a calculated field. The first query is if all records are
to be treated together.
SELECT Column1, Column2, (SELECT COUNT(*)
     FROM [YourTable-4] T1
     WHERE  T1.Column2 <= T.Column2) AS Rank
FROM [YourTable-4] AS T
ORDER BY Column1, Column2;

If you need grouping then use this query instead.
SELECT Q.Group, Q.Points, (SELECT COUNT(*) FROM Product Q1
     WHERE Q1.[Group] = Q.[Group]
       AND Q1.Points < Q.Points)+1 AS Rank
FROM Product AS Q
ORDER BY Q.Group, Q.Points;

Use the one that fits your situation.  Then in another query design view
select the above query of choice twice.  Access adds a sufix of '_1' to the
second instance of the query.
Join the two queries by clicking on the field names and draging to the
other.  Then to see data from two consecutive records add the data field from
the '_1' query and the Rank field also.  Use criteria on the '_1' Rank field
of [FirstQuery].[Rank]+1 or [FirstQuery].[Rank]-1 according to whether you
want to look forward or backwards.

Signature

KARL DEWEY
Build a little - Test a little

> I have created QueryTable from MainTable showing data sorted by StartDateTime. Is there a formula or way of updating the added column QueryTable.PreviousEndDateTime with the value of QueryTable.EndDateTime from the previous row in the query for each record in the query?
>
> The end result is to show the MainTable data in a form by start date/time order whilst alerting that the previous records end date/time field is different to the current records start date/time field. Records in MainTable may be in any order as it stores times on each job for different people.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.