Solved

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

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now