Results 1 to 6 of 6
  1. #1
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107

    Added records not displaying in subform

    I have another one of those "head scratchers". I have Form1 that I enter criteria for a query on. As I enter the different criteria fields, SubForm1 on Form1 lists records that fit the criteria. Everything is good so far. To change a record, I click on the record in SubForm1 and Form2 for editing a single record opens. When I close Form2, I update Form1 with the following code:


    Private Sub Form1_GotFocus()
    Forms!Form1!SubForm1.Requery
    Me.Refresh



    End Sub


    The record updates on Form1 correctly. I only run into a problem when I add a new record. I add a new record by clicking on the Add New Record line at the bottom of the list in SubForm1. Form2 pops up and allows me to add the record. When I close Form2, the new record doesn't show on SubForm1. It WILL display if I hit the <F5> key. I've tried the following:


    Private Sub Form1_GotFocus()

    Forms!Form1!SubForm1.Requery
    Me.Refresh
    SendKeys "{F5}"

    End Sub


    AND:


    Private Sub Form1_GotFocus()

    Forms!Form1!SubForm1.Requery
    Me.Requery
    SendKeys "{F5}"

    End Sub


    AND:


    Private Sub Form2_Close()

    Forms!Form1!SubForm1.Requery
    Forms!Form1.Requery

    End Sub


    None of these have worked. Can someone tell me if my code, my event, or both are wrong?

    Thanks!

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by From Access Help
    A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur.
    Try using the Form's OnActivate event, instead.

    Linq ;0)>
    Last edited by Missinglinq; 02-12-2016 at 08:47 AM.
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107
    I tried it, and I got the same results.

    Quote Originally Posted by Missinglinq View Post
    Try suing the Form's OnActivate event, instead.

    Linq ;0)>

  4. #4
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    just a sanity check: you add a new record in Form 2, close it. Then close Form 1. Open Form 1: the new record will then be find-able .... yes?

  5. #5
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107
    Yes, that is correct. In fact, I can just hit <F5> and the new record(s) appear.

    Quote Originally Posted by NTC View Post
    just a sanity check: you add a new record in Form 2, close it. Then close Form 1. Open Form 1: the new record will then be find-able .... yes?

  6. #6
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    The close of Form2 triggers the write of the new record to its table. So that in the Close event of Form2 you should be able to have just:

    Forms!Form1!SubForm1.Requery

    if this is not working; define where the tables are physically located. Is this a split db and if so is the BE file co-located on the same PC or LAN? ..... if not move it there just for testing purposes.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-26-2015, 12:19 PM
  2. Replies: 3
    Last Post: 04-23-2014, 12:19 PM
  3. Problems with Subform displaying records
    By Astron2012 in forum Forms
    Replies: 2
    Last Post: 09-07-2012, 05:56 AM
  4. Replies: 2
    Last Post: 05-02-2012, 09:16 PM
  5. Replies: 12
    Last Post: 04-25-2012, 08:06 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