How to show records on 2nd subform when 1st subform is activated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shona Rennie

    #1

    How to show records on 2nd subform when 1st subform is activated

    I have the following in a form:

    - Main Form which stores EE details [Mileage Expense Form]

    - 1st subform [SubFSiteInfo] - a continuous form with a combo box which allows either selection of an existing contract or option to open a Contract Form to add.

    - 2nd subform [SubFMileageInfo] - a continuous form which shows employee travel information relative to the contract number they are working on at that time.

    This all works fine and returns the correct records.

    However, when you go back into the form and click on a record on the 1st subform, the related records to not show on the 2nd subform until you click on to the 2nd record of the first subform then click back on to the first record.

    I assume that there is something wrong with the requery.

    I have the following code in the On Current event of the 1st subform:

    Code:
    Sub Form_Current()
    ' This code created by Form Wizard.
        Dim strParentDocName As String
    
        On Error Resume Next
        strParentDocName = Me.Parent.Name
    
        If Err <> 0 Then
            GoTo Form_Current_Exit
        Else
            On Error GoTo Form_Current_Err
            Me.Parent![SubFMileageInfo].Requery
        End If
    
    Form_Current_Exit:
        Exit Sub
    
    Form_Current_Err:
        MsgBox Err.Description
        Resume Form_Current_Exit
    End Sub
    Any and all advice would be very much appreciated.

    Shona
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Quote:However, when you go back into the form and
    Go back into the form from where? Where have you been and what where you doing? Depending on what you were doing (or not doing) in the meantime the Current might not execute.

    2 things to suggest:
    1. Add a (temp) msgbox to your Current event, allowing you to see whether or not it fires at runtime.
    2. Use Private Sub Form_GotFocus() instead

      If neither of these work, you can try uploading the db and I can take a look at it.

    Comment

    Working...