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
Solved

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

Posted on 2014-02-04
2
1,795 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

790 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