Search code examples
ms-accessvbasubform

SubForm Select Row and Edit Source


I have a SubForm ("Main Menu SubForm") that is on a MainForm ("Main Menu")... I want to select a row on the SubForm and it then pull the corresponding row into another form for edit.

I have the following code but it doesn't seem to do what I expect:

Private Sub Form_Activate()
    Me.Requery
    If IsLoaded("Main Menu") Then
        If Forms![Main Menu]![Main Menu SubForm].Form.RecordsetClone.RecordCount > 0 Then
            DoCmd.GoToControl "txtWOrderID"
            DoCmd.FindRecord Forms![Main Menu]![Main Menu SubForm].Form![WOrderID]
        End If
    End If
End Sub

I have attached a link to my database for reference if needed: Access Invoice System


Solution

  • I wound up getting it to work by doing this from the Main Form:

    Private Sub btnViewWorkOrder_Click()
        DoCmd.OpenForm "Work Order", acNormal, , "[WOrderID] = '" & Forms![Main Menu]![txtWOrderID] & "'", acFormEdit, acDialog
    End Sub