Results 1 to 12 of 12
  1. #1
    kowalski is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    10

    SubForm will not update after an insert

    Hi, I've seen many similar posts to this but nothing suggested seems to b working.

    I have a form (frmSegments) with a sub form (sfrmSegments).
    I update a field in the sfrmSegments and it triggers some code which does an insert (AddNew/Update) on the recordset.
    I then want these new rows to display in the sub Form.
    If I go to the next record (main form) and then back again, I see the new rows in the subform.
    But the rows won't display otherwise.

    I have tried combinations of the following to get the new row to display without success...



    [Forms]![frmSegments].Requery
    [Forms]![sfrmSegments].Requery


    Me.Parent.Requery
    Me.Parent.Repaint


    Me.Requery
    Me.Repaint

    Cheers in advance!!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Perhaps this link will shed some light on the subject: http://access.mvps.org/access/forms/frm0031.htm

  3. #3
    kowalski is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    10
    Quote Originally Posted by RuralGuy View Post
    Perhaps this link will shed some light on the subject: http://access.mvps.org/access/forms/frm0031.htm

    Thanks ...
    So my code to add the new row and then requery is in the SubForm code. And I have tried this...

    [Forms]![frmSegments].Requery

    [Forms]![sfrmSegments].Requery

    So I would think that it should requery the database and display the new row. But it's still not showing me the new row. Any ideas?

    Cheers.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If the code is in the SubForm then how about Me.Requery?

  5. #5
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    I update a field in the sfrmSegments and it triggers some code which does an insert (AddNew/Update) on the recordset.
    Why do you do this.

    The save will happen when the record loses focus. So there is no need to do this at all.

  6. #6
    kowalski is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    10
    Quote Originally Posted by RuralGuy View Post
    If the code is in the SubForm then how about Me.Requery?
    I have tried a Me.Requery but that does not display the new record.
    Thanks.

  7. #7
    kowalski is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    10
    Quote Originally Posted by Rainlover View Post
    Why do you do this.

    The save will happen when the record loses focus. So there is no need to do this at all.
    The functionality is that I have a field called Number of Segments on the subform. This is defaulted to "1". in which case there is only a single record (in the subform). The user updates this to 2 or 3, ... And that many fields are created in the background via code. So the user enters 2, the code on the event for that control creates a second record, duplicating a bunch of information from the first record. That second record is created in the code using AddNew/Update.

    Thanks.

  8. #8
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    copy-paste the following command in ur vba code...it should work...

    SendKeys "+({f9})"

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by kowalski View Post
    I have tried a Me.Requery but that does not display the new record.
    Thanks.
    Then the new record has not been created yet!

  10. #10
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Quote Originally Posted by RuralGuy View Post
    Then the new record has not been created yet!
    That being the case, we need to see the code that creates the new records.

    What we are doing now is guessing.

  11. #11
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    From what you describe, the main form has code to create new records you want to see in the subform. you have the right idea, that you need to requery the subform, but your syntax is incorrect. Try this:

    me![subformcontrolname].form.Requery

    Note that subformcontrolname is the name of the control on the main form that contains the subform; it is not the name of the subform itself.

    HTH

    John

  12. #12
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Quote Originally Posted by Rainlover View Post
    That being the case, we need to see the code that creates the new records.

    What we are doing now is guessing.
    I just had a thought. After this insert and in the sane code segment run a command to open the Table just to see if the information has been added.

    Don't forget to remove this when the problem is solved.

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

Similar Threads

  1. UPDATE and INSERT
    By csako1 in forum Access
    Replies: 3
    Last Post: 01-05-2012, 06:37 PM
  2. if exists UPDATE else INSERT
    By lloyddobler in forum Programming
    Replies: 18
    Last Post: 01-04-2012, 11:35 PM
  3. Insert/update value of Access Table via UDP
    By Yance in forum Programming
    Replies: 1
    Last Post: 03-21-2011, 06:57 PM
  4. update vs. delete / insert
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 09-23-2010, 07:44 AM
  5. INSERT INTO and UPDATE to multiple tables
    By lupis in forum Import/Export Data
    Replies: 6
    Last Post: 05-19-2010, 05:21 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