Filtering subform..

CrystalSurfer

Matrix activist
Local time
Today, 12:03
Joined
Jan 11, 2006
Messages
75
Yes, Ive searched the forum and Im still stuck on this most basic of concepts - please can someone point me in the right direction?..

I have a Form [frmClient] and a subform [sbfrmCommsList]. The subform links nicely with the main form via [ID]. However I want to add a second filter on the subform selecting only [Type] = 2 rows (from the child table)

This is in the subform:

Code:
Private Sub Form_Load()

Me.Form.Filter = "Client=" & Me.Client & " AND Type =2"
Me.Form.FilterOn = True
Me.Form.Requery

End Sub

It still displays all records (Both [Type] 1 and 2)...
thanks..
 
Solved it!
I put the code in the wrong sub procedure - it should have been in the Form_Current() one not the Form_Load().

I guess Form_Load is literally when the screen gets called? so not the right place to set a filter for a Tab control?
 
:D Woohoo!!! I was just about to post a follow up question... but I solved it. Now I thought I'd spread the good word to the rest of you!

I was trying to use this same code for my form. Only, in my case I want this code to be applied in the After Update event because I want the filter to be based upon a drop down menu. I kept running into a problem where it wouldn't identify my drop down list. This is what I came up with, notice the "'" used to put the value in quotes (apostrophes).

Private Sub Find Contractor_AfterUpdate()
Me.Form.Filter = "[Contractor]= " & "'" & Me.FindContractor & "'"
Me.Form.FilterOn = True
Me.Form.Requery
End Sub
 

Users who are viewing this thread

Back
Top Bottom