Domanda

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

È stato utile?

Soluzione 2

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

Altri suggerimenti

I would do something like (and this is aircode, so it needs tweaking):

forms!WOrderID.RecordSource = "Select * from MyTable where WOrderID = " & me.txtWOrderID & ""
Forms!wOrderID.Refresh
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top