Open form to show subform record

N

Nick Mirro

Button "btnScript" is located on one of the "come from" form's subforms.

I'd like to use btnScript to open a parent form "frmProcMusSkel" and have
one of its specific subform records be displayed.

**So parentmost form keys need to be linked first, followed by subform keys
(I think)**


ParentToLink SubFormToLink

(Come from form)

Name frmInjuryInfo sbfrmVisit
Level 1 3
Primary key PatientID VisitID


(Go to form)

Name frmProcMusSkel sbfrmBilling
Level 1 2
Primary key PatientID VisitID



Here's what I have, which naturally doesn't work ]:~(



Private Sub btnScript_Click()
On Error GoTo Err_btnScript_Click

Dim frm As Form

DoCmd.OpenForm "frmProcMusSkel", _
WhereCondition:="PatientID=" & Forms!frmInjuryInfo.PatientID

Set frm = Forms!frmProcMusSkel!sbfrmBilling.Form

With frm.RecordsetClone
.FindFirst "VisitID=" & Me.VisitID
If Not .nomatch Then
frm.Bookmark = .Bookmark
End If
End With

Set frm = Nothing

Exit_btnScript_Click:
Exit Sub

Err_btnScript_Click:
MsgBox Err.Description
Resume Exit_btnScript_Click

End Sub



How can I correct this to work properly, short of taking a desparately need
vb course?

Nick
 
N

Nick Mirro

I think I've got it. The subform was linked to parentform by the same field
that was used to locate the subform record. The subform recordset was
already filtered to one visit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top