Share via

Filter Subform with Listbox

Anonymous
2022-06-29T13:52:11+00:00
  1. Main form is unbound
  2. Listbox (List1) row source - SELECT Code, Customer, Description FROM Jobs;
     bound column - Code        
    
  3. Subform1 - record source - Jobs_Invoices (query) - datasheet view

the Jobs_Invoices query has 1-M relationship where Jobs has the primary key (Code) and Invoices has the foreign key (Inv_Det_Code).

The code below does not filter the subform when the list is clicked. Is the syntax incorrect?

Private Sub List1_Click()

Me.Filter = "([Me!Subform1.Form!Inv_Det_Code])" = " & Me.List1.Value"

Me.FilterOn = True

End Sub

Microsoft 365 and Office | Access | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2022-06-30T01:21:16+00:00

Private Sub List1_Click()

Me.Subform1.Form.Filter = "Inv_Det_Code = " & Me.List1

Me.Subform1.Form.FilterOn = True

End Sub

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-06-29T16:28:22+00:00

    No luck. Do I bound the main form, subform, and list box all to the same Query? then Master link the list field and child link the subform field?

    Also, my listbox is showing multiple records with the same job number - where I only wanted unique job #s for the list box to click and display all invoices in the subform from that job.

    Was this answer helpful?

    0 comments No comments
  2. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2022-06-29T14:42:21+00:00

    The listbox, which has a value of JobCode.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-06-29T14:41:04+00:00

    What would I use as the LinkMasterField? Does the Listbox need the same control source as the subform?

    Was this answer helpful?

    0 comments No comments
  4. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2022-06-29T14:30:31+00:00

    Would it be easier to set the subform control's LinkMasterFields and LinkChildFields?

    Was this answer helpful?

    0 comments No comments