I have two forms that both use a comments subform. However, depending on which group opens the form is which textbox for the Claim id to be drawn from. I tried the Me.Parent, but that did not work to identify which form the subform was being used on.
Private Sub CmdNew_Click()
On Error GoTo Err_CmdNew_Click
DoCmd.GoToRecord , , acNewRec
If Me.Parent = Forms!frmACHClaims Then
Forms.FrmNotesView.TxtClaimID = Forms!frmACHClaims!TxtClaimID
Forms.FrmNotesView.ComClaimID = Forms!frmACHClaims!TxtClaimID
ElseIf Me.Parent = Forms!FrmClaims Then
Forms.FrmNotesView.TxtClaimID = Forms!FrmClaims!TxtClaimID
Forms.FrmNotesView.ComClaimID = Forms!FrmClaims!TxtClaimID
MsgBox "Error Number: " & Err.Number & _
"Description: " & Err.Description & _
"Procedure: CmdNew_Click", vbOKOnly, "Error Message"