Results 1 to 7 of 7
  1. #1
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155

    Transferring Latest Entry from Subform to Field in Main form on Load

    Hey,

    See screenshot below. I would like the latest entry for the Subform Status History (tblStatusHistory subform) also be visible in the field CurrentStatus in the main form (frmSystemsTracker) when loaded (and write to the main table). Is this possible? The subform is linked to the main from via the "ID" field name (neither visible in the screenshot)

    Any thoughts are greatly appreciated!

    I have three seperate tables/forms:

    tblFollowUpInfo -- tblFollowUpInfo subform
    tblStatusHistory -- tblStatusHistory subform


    tblSystemsData -- frmSystemsTracker


    Click image for larger version. 

Name:	screenshot.JPG 
Views:	19 
Size:	38.1 KB 
ID:	8863

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Why duplicate this value to the main table? That violates relational database principle not to duplicate data. It is just bad idea to save dependent data that can be calculated whenever needed.

    You need to retrieve the status associated with the latest date. I suggest nested domain aggregate functions. In textbox ControlSource like:

    =DLookup("Status", "tblStatusHistory", "[Date]=#" & DMax("[Date]","tblStatusHistory","WorkOrderID=" & [WorkOrderID]) & "#")

    Then will need code to save the value to table. The trick is figuring out what event to put the code in:
    Me!Status=Me.StatusTextboxName

    What do you want to happen if a new entry is made to the History subform?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    I would jsut assume it would update the status each time they opened. If they put in a new status, they would just have to close to see the current status portion update.

    Now, the field name of Date is dte (in both the form and subform). And the subforms are linked by ID. So should the textbox read:

    =DLookup("Status", "tblStatusHistory", "[Dte]=#" & DMax("[Dte]","tblStatusHistory","ID=" & [ID]) & "#")

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Looks right. Try it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    Did not work. I ended up with #Error.

  6. #6
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    Spelling error. It works. Thanks so much!

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    That often means Access can't find name or there is syntax error.

    I don't know if you have misspelled a name but syntax looks correct.

    However, my suggested expression was incomplete. The outer DLookup also needs ID as criteria.

    =DLookup("Status", "tblStatusHistory", "[Dte]=#" & DMax("[Dte]","tblStatusHistory","ID=" & [ID]) & "# AND ID=" & [ID])

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-14-2012, 10:08 AM
  2. Capturing Latest Entry on Subform
    By Marie1106 in forum Forms
    Replies: 3
    Last Post: 02-21-2012, 10:40 AM
  3. Replies: 9
    Last Post: 12-15-2010, 01:44 PM
  4. Replies: 1
    Last Post: 11-13-2010, 12:57 PM
  5. Replies: 3
    Last Post: 11-05-2010, 03:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums