Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…

760 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

18 Experts available now in Live!

Get 1:1 Help Now