Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65

    Sub-Sub-Form Saving

    Presently I have 3 forms: Parent, Sub, Sub-Sub. I have three buttons on Sub-Sub.
    1. Save Sub-Sub and add another
    2. Save Sub and add another (which includes Sub-Sub)


    3. Save Parent (which includes Sub and Sub-Sub)

    I have no problem with saving Sub-Sub.
    DoCmd.GoToRecord , , acNewRec

    However, I am having trouble saving the data for 2 and 3 without overwriting everything. The code is saving the data, then replacing it with null values (because I am apparently telling it to). In my mind, I just want it to erase it so I can enter new information. However, I set each field to Null after I save and that's obviously not a good idea.

    Question: How do I save the information, clear out parts of it, but not erase my hard work? Thank you.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Move to new record row.
    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
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    How can I get my button to do that?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Depends were the buttons are located.

    You say they are all on sub-subform?

    Need to set focus to form where want to move to new record row.
    Review https://www.accessforums.net/access/...red-40057.html
    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
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    What is to be used as a container control?

    I added a button to the Sub-Form called ctrAgent and this code to the Sub-Sub-Form button:

    Me.Parent!ctrAgent.SetFocus
    DoCmd.GoToRecord , , acNewRec

    No dice. "Can't move the focus to the control ctrAgent"
    I'm not really sure where these pieces should all go.
    Last edited by QuantifyRisk; 09-15-2014 at 12:19 PM.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    A subform is created by placing a subform/subreport container control on another report. The container control SourceObject can be table, query, form, report.

    I always name container control different from the object it holds, like: ctrAgents if it holds the frmAgents.

    Code in a subform that dictates behavior of upper forms is unusual. Don't think I've ever tried that. It just might not work.
    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.

  7. #7
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    I'm having quite a bit of trouble with this for that reason. Not a lot of help online for Sub-Sub-Forms. However, I was able to screw around with it enough to get this to work:

    Me.Parent.Form!ExpirationDate.SetFocus
    DoCmd.GoToRecord , , acNewRec

    This was on a click() and saved/cleared the record in the sub-form. However, I now need to do the same to the Parent form rom the Sub-Sub-Form. I tried:

    Me.Parent.Form!ExpirationDate.SetFocus
    DoCmd.GoToRecord , , acNewRec (to save the Sub-Form)
    Me.Form!PhysicalZipCode.SetFocus
    DoCmd.GoToRecord , , acNewRec (to save the parent form)

    Didn't do it. Gave me a 2110 error and said something about the "Main Screen" which is the title of my main menu that loads on startup. Not sure why it went that far.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Well, the sub-subform has to go up two levels. So maybe Me.Parent.Parent ?
    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.

  9. #9
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    Error 438 for that. I figured I would just go up one level since the prior lines went up one already.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    The Me refers to the form the code is behind, not the form that has focus. So by using Me, you make the starting point the sub-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.

  11. #11
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    I tried:

    Me.Parent.Form!ExpirationDate.SetFocus
    DoCmd.GoToRecord , , acNewRec
    Me.Parent.Parent.Form!EstimatedTotalPremium.SetFoc us
    DoCmd.GoToRecord , , acNewRec

    I know the first two lines work because it clears them out. However, the next two do not. Oddly enough, if I remove the first to, I still get "Error 438: Object doesn't support this property or method". Happens even when I changed to a different field, too. It almost makes me think it's a syntax issue. I may just move it to the Parent form and say screw it.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    You are doing something I've never tried. According to this http://access.mvps.org/access/forms/frm0031.htm Parent.Parent should work.
    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.

  13. #13
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    Microsoft provides this as a help:

    There are two possible workarounds for this problem.

    • Access the form directly rather than by a variable containing the form.
      -or-
    • Create property procedures in the form's code to provide access to the properties of the controls on the form.


    Not sure how to do this though. Thanks.

  14. #14
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    Yeah. That site is what I'm using to help but it is just not clicking. I wonder if it's a form property or some other minor issue that's stopping it from working.

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Sorry, you are on your own from here unless someone else jumps in.
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form validation before saving
    By BDevil15 in forum Access
    Replies: 3
    Last Post: 09-01-2014, 07:22 AM
  2. Form not saving records
    By jree3000 in forum Forms
    Replies: 9
    Last Post: 06-17-2014, 07:01 PM
  3. Replies: 10
    Last Post: 10-22-2013, 07:35 AM
  4. saving a form
    By Ray67 in forum Forms
    Replies: 11
    Last Post: 10-23-2011, 06:45 PM
  5. Closing and saving a form
    By Lxmanager in forum Forms
    Replies: 14
    Last Post: 11-21-2010, 02:04 AM

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