I've got a subform in Access which represents the junction table in a many-to-many relationship.
Specifically, it's based on a query which includes values across all 3 tables (People, Trips, People_Has_Trips). The subform (subfrmTripsPeople) is part of the main form (Trips). It shows contact information, and includes a button labeled "Edit this person", the intended purpose of which is to open the People form to the selected record in the subform. This seemed like the right call over just having the fields be editable from the subform, to be sure the user clearly intends to edit the user.
Here's the VBA code I have so far:
Private Sub cmdEditPerson_Click()
Dim selectedPerson As Integer
selectedPerson = Me.subfrmTripsPeople.Form!People_PersonID
DoCmd.OpenForm "People", , , "ID = " & selectedPerson
End Sub
When I go into the form and click "Edit this person", I get "Compile Error: Method or Data Member not found" with subfrmTripsPeople highlighted in blue and the Private Sub line highlighted in yellow in the VBA editor. So it seems I've discovered an incorrect way to do this. What, then, have I done wrong and what is the correct way to do this?
The obvious issue, in my mind, would be that I'm referencing the field People_PersonID which isn't actually a field on the subform, though I assumed it would be accessible since it's part of the underlying source query. Yet, the highlighted code would seem to indicate that my error lies in the way i refer to the subform. I can't see what would be wrong with this, and I haven't misspelled the name or anything.
Would appreciate guidance on this issue!
People_
prefix? – June7