Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-02-04
2
Medium Priority
?
1,933 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 2000 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 58
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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

636 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