Results 1 to 9 of 9

Form update with new data in sub-subform.

  1. #1
    Degs29 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2013
    Posts
    38

    Form update with new data in sub-subform.

    I've set a control to automatically update certain fields in my main form when I update my subform or sub-subform. This works fine when updating the subform. But when I update my sub-subform, once I update the data and go to new record, it auto-updates the main form, but then sets the focus back on first record of the sub-subform. This is functional, but very annoying. I want the focus to remain on the first field of the new record on the sub-subform.

    Anyone know what the cause of this might be?

  2. #2
    Bob Fitz is online now MS Community Contributor
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    1,345
    You don't say how you
    automatically update certain fields in my main form when I update my subform or sub-subform
    but if this is done with code in the subforms After Update event, then perhaps you could add one line of code at the end to go to a new record.
    If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
    Not everyone can access an accdb, you may reach a broader audience by attaching in mdb format.

    Bob Fitzpatrick

    I have never failed. I have found a thousand ways that do not work!

    Microsoft Community Contributor Award (2011)



  3. #3
    Degs29 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2013
    Posts
    38
    Quote Originally Posted by Bob Fitz View Post
    You don't say how you but if this is done with code in the subforms After Update event, then perhaps you could add one line of code at the end to go to a new record.
    And that line of code would be...?

    Yes, you're right, the updating is done using the sub-subforms After Update event.

  4. #4
    Bob Fitz is online now MS Community Contributor
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    1,345
    Try:
    DoCmd.GoToRecord , , acNewRec
    If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
    Not everyone can access an accdb, you may reach a broader audience by attaching in mdb format.

    Bob Fitzpatrick

    I have never failed. I have found a thousand ways that do not work!

    Microsoft Community Contributor Award (2011)



  5. #5
    Degs29 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2013
    Posts
    38
    Quote Originally Posted by Bob Fitz View Post
    Try:
    DoCmd.GoToRecord , , acNewRec
    Nope. It's still jumping back to the first record after the sub-subform's after_update event is complete. I've never seen this before, and assume it has something to do with the form being a sub-subform.

  6. #6
    Degs29 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2013
    Posts
    38


    No one has any ideas how to fix this? Just to clarify, using the exact same method, I can update the main form fields based on the first-level subforms after_update control and the cursor (active field) remains in the correct location. But when I use the exact same method for the second-level subform, the cursor moves to the first record of that subform, rather than staying in the correct location.

    I suppose I could ditch the automatic updates, and just use a command button on the main form to manually update the fields, but that's almost as much a hassle as the cursor moving of its own accord.

  7. #7
    Degs29 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2013
    Posts
    38
    Oh, wow! Can't believe this worked. Basically, rather than using a requery to update the fields, I used a refresh of the main form and combine it with the above suggestion and a SetFocus command to get the cursor where I want it:

    Code:
    Forms![Mainform].Form.Refresh
    DoCmd.GoToRecord , , acNewRec
    Me.[1stfield].SetFocus
    If I didn't set the focus of the new record to the 1st field, it would still move the cursor to the new record, but in the last field.

  8. #8
    Bob Fitz is online now MS Community Contributor
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    1,345
    Quote Originally Posted by Degs29 View Post
    Nope. It's still jumping back to the first record after the sub-subform's after_update event is complete. I've never seen this before, and assume it has something to do with the form being a sub-subform.
    Can you show us your code and tell us in which event it is being used.
    If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
    Not everyone can access an accdb, you may reach a broader audience by attaching in mdb format.

    Bob Fitzpatrick

    I have never failed. I have found a thousand ways that do not work!

    Microsoft Community Contributor Award (2011)



  9. #9
    Degs29 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2013
    Posts
    38
    Quote Originally Posted by Bob Fitz View Post
    Can you show us your code and tell us in which event it is being used.
    I'm using the sub-subforms after_update event.

    I had been using the code (With "Mainform" and "Field_n" subbing for actual names):

    Code:
    Forms![Mainform]![Field1].Requery
    Forms![Mainform]![Field2].Requery
    Forms![Mainform]![Field3].Requery
    But see previous post for the solution that ultimately worked. Thanks for your contribution!

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

Similar Threads

  1. Replies: 3
    Last Post: 06-19-2013, 01:39 PM
  2. Replies: 8
    Last Post: 05-30-2013, 04:06 PM
  3. Open form with subform No Update
    By insane53 in forum Forms
    Replies: 1
    Last Post: 01-06-2012, 12:46 PM
  4. Replies: 0
    Last Post: 05-09-2010, 07:43 AM
  5. Form/Subform - Update control help!
    By f_ali in forum Forms
    Replies: 2
    Last Post: 02-25-2006, 10:59 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
  •  
Tech Forums: Microsoft Office Forums