filtering subform2 based on subform1

lazynewt

Registered User.
Local time
Today, 06:53
Joined
May 20, 2008
Messages
15
Hi guys

i have 1 mainform and within this i have
-subform1 ----this form contains listed data
-subform2 ----this form contains listed data

subform 1 has specific data which is [dob] which is pulled from table [customers]

subform 2 also has data [dob] which is pulled from [apps]

There is a button next to each record on subform1. When clicked it needs to filter subform2 and only display records that contan the same dob. This is the code i am trying to get to work.

Code:
Private Sub Command28_Click()

Dim f As Form

Set f = Parent!subform2.Form                '


f.Filter = "[DOB]=" & Me![DOB] & "'"
f.FilterOn = True



End Sub
can someone point out where im going wrong filtering. No matter what variation i use i cant get it to filter based on the dob on subform1..

thanks in advance.
 
Try using the full subform reference instead of using the Me shortcut.
 
will that relate to specific record that the onclick button is in ?

thanks
 
is this wrong ?

Code:
f.Filter = [DOB] = " &  Me!subform1.Form!DOB"
i can see the refresh but it doesnt seem to be filtering. :confused:
 
Last edited:
Hi There

if the subform is based on the mainform, why isnt it automatically filtered? this should be a pretty simple excerise in the sense of adding the subform and using the wizard to select what type of connection is required. you select the data to to link the forms together and it is the automatically filtered.

NS
 
Im not sure if im explaining myself correctly or i might be missunderstanding.

1 main form = linked to nothing (this is just a blank form)

subform1 = contans listed data from table1

subform2 = contains listed data from table2

i am trying to have 1 button per record in table1 that when clicked will filter table2.

Both table 1 and table 2 contain a field called DOB.
 
Re: resolved.

i had an error with my filter code. -
Code:
f.Filter = "[DOB]=" & "#" & Me![DOB] & "#"
Problem solved.
 

Users who are viewing this thread

Back
Top Bottom