Solved

Microsoft Access 2007 continuous form -  refer to value in previous row

Posted on 2014-02-04
2
1,820 Views
Last Modified: 2014-02-05
I need to have a field in a continuous form use a value from the previous row.

Using the "Order" field and the first Start Date  I need the rest of the "Start" fields to fill in.
The first "Start" and "End" fields are calculations in the underlying query.

The remaining starts field values (in order) would use  "End" + 1

Order      Start            End

1      2/17/14            2/22/14
2      2/23/14
3            

I have attached an example db.   The Project Form has a subform on it that shows tasks.  That is where I need the help.
ML-Test.accdb
0
Comment
Question by:mlaurin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
Gozreh earned 500 total points
ID: 39834562
Your Startdate should be =[Required_Start]+Nz(DSum("[T_Aggressive_duration]","Tasks_tbl","Project_ID=" & [Tasks_tbl]![Project_ID] & " AND Order<" & [Order]),1)

and the enddate =[Required_Start]+DSum("[T_Aggressive_duration]","Tasks_tbl","Project_ID=" & [Tasks_tbl]![Project_ID] & " AND Order<=" & [Order])
ML-Test.accdb
0
 
LVL 57
ID: 39835478
For something a little more generic, you may want to look at this:

How to fill a record with data from a previous record automatically in Access 2000 and 2002 and Office Access 2003
http://support.microsoft.com/kb/210236

also along the same lines, and closer to you question, is the code below.

Jim.

Function GetPreviousRow(frm As Form, strFieldName As String)

        ' Fetches value of field from previous row
       
        Dim strBM As String
        Dim rstClone As Recordset

        ' Get the bookmark for the current row.
10      strBM = frm.Bookmark

        ' Now create the record set clone, and make it
        ' refer to the same row as rst, which is on the same
        ' row as the form.
20      Set rstClone = frm.RecordsetClone.Clone()
30      rstClone.Bookmark = strBM

        ' Move the clone record set to the previous row.
        ' If this puts us at the BOF, then the result has to be
        ' FALSE, and leave the function.
40      rstClone.MovePrevious
50      If rstClone.BOF Then
60        GetPreviousRow = False
70      Else
          ' If you're not at BOF, then retrieve the necessary info.
80        GetPreviousRow = (frm.RecordsetClone(strFieldName) = rstClone(strFieldName))
90      End If

100     rstClone.Close

End Function
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question