Solved Filtering Subform based off carried over data

bonzitre

Member
Local time
Today, 05:20
Joined
Feb 9, 2024
Messages
31
Hello again everyone.
Today, my issue is I am trying to filter a subform based on the data I am carrying over from another form.

I have a form "PatientForm" that has a button "cmdViewCalls" with the following code:

Private Sub cmdViewCalls_Click()

Code:
Private Sub cmdViewCalls_Click()

Dim strFrmName As String
strFrmName = "CallLogView"

    DoCmd.OpenForm strFrmName
        With Forms(strFrmName)
            .MRNcall = Me.MRN
            .LastNamecall = Me.LastName
            .FirstNamecall = Me.FirstName
            .DOBcall = Me.DOB
            .PatientIDcall = Me.ID
        End With
End Sub

It opens form "CallLogForm" and fills in unbound boxes with info from the PatientForm form. I then use that data to create a header with those fields so the user will know they are looking at the correct person's data as below while the PatientIDCall box is the primary key for the patient which is hidden on the form.

1707759781872.png


The subform "PTCallSub" is based on a form PtCallLogF which is just a datasheet form of PtCallLogQ (query) which is a query of the CallLog Table.

What I am trying to do, is make it to where when the form/subform loads, it will filter the PtCallLogQ to display only records related to the patient that the primary key PatientIDCall hidden box has filled in. I can't for the life of me get anything to work.
Those unbound boxes are the boxes I referred to.
1707760096540.png


If you need more information, let me know. Thanks!
 
Hi. Welcome to AWF!

Try setting the Master/Child Linked Fields of the subform to use the hidden textbox as the master and the foreign key in the query as the child.
 
, is make it to where when the form/subform load
for a form, use the where parameter of the openform method

for a subform, use the linkchild/master properties of the subform control
 
Hi. Welcome to AWF!

Try setting the Master/Child Linked Fields of the subform to use the hidden textbox as the master and the foreign key in the query as the child.
Edit:
I just typed PatientIDCall as the parent and PatientID as Child and viola. Thank you guys! stupid simple which I assumed it would be.

OLD: When I attempt to do that, I don't have the option to select PatientIDCall (the box with the ID I want to use to filter) which is housed on the main form?
 
The main form and subform should be linked by the patients PK, forget about the unbound textbox.
Then you simply use docmd open form to the correct ID. The subform will filter automatically.
 

Users who are viewing this thread

Back
Top Bottom