Results 1 to 2 of 2
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    192

    Forms do not refresh immediately

    I have a module tied to a control in a form. This module refreshes the form.
    There seems to be a lag in how quickly it refreshes.
    Sometimes, you have to click around in the form to get it to refresh, or manually hit shift+F9 to get the form to refresh.

    I have a query that updates a table if the value in this form is changed. It's called from the Afterupdate property of the control, then on Exit, I call the module.
    The change is happening in a form, (Table 1) and updating fields in a subform (Table 2) based on the changes made.
    Thank you!

    Any thoughts on improving this?

    Option Explicit


    Public Sub RefreshForms()
    On Error GoTo ERR_HANDLER

    Dim i As Integer
    For i = 0 To Forms.Count - 1
    Call RefreshForm(Forms(i))
    Next

    EXIT_PROC:
    Exit Sub

    ERR_HANDLER:
    MsgBox Err & vbCrLf & Error$
    Resume EXIT_PROC:
    End Sub




    Private Sub RefreshForm(frmForm As Form)
    On Error GoTo ERR_HANDLER

    Dim i As Integer
    With frmForm
    .Recalc
    For i = 0 To .Controls.Count - 1


    Select Case .Controls(i).ControlType
    Case acComboBox, acListBox, acSubform
    .Controls(i).Requery
    End Select
    Next
    .Refresh
    End With

    EXIT_PROC:
    Exit Sub

    ERR_HANDLER:
    If Err.Number = 2478 Then
    Resume Next
    Else
    MsgBox Err & vbCrLf & Error$
    Resume EXIT_PROC
    End If
    End Sub

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

    If I recall correctly, the subform is not included in the Forms collection, so your loop in RefreshForms will not update (requery) it.

    You might try something like this (untested):

    Call RefreshForm(me!subformcontrol.form)

    It should still work, since it is passing a form reference to RefreshForm

    HTH

    John

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

Similar Threads

  1. Replies: 6
    Last Post: 01-29-2014, 02:03 PM
  2. Using forms to immediately edit/update a table
    By TKTheKid in forum Reports
    Replies: 18
    Last Post: 11-19-2012, 11:58 PM
  3. Immediately update table with form?
    By Rosier75 in forum Forms
    Replies: 6
    Last Post: 06-08-2012, 09:11 AM
  4. Access 2010 Refresh VS Refresh ALL
    By Snwboarder1982 in forum Access
    Replies: 1
    Last Post: 09-09-2011, 04:07 PM
  5. Don't want to save forms on Refresh or closing
    By accesscoder in forum Forms
    Replies: 5
    Last Post: 09-25-2010, 12:03 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