Results 1 to 9 of 9
  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's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    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.
    Bob Fitzpatrick

  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's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    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.
    Bob Fitzpatrick

  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's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    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.
    Bob Fitzpatrick

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