Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code not working 1

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
579
0
16
GB
Hello I am trying to filter a subform from another subform using the on current event.

Code:
Forms![frm_Contractor_Job]![Subfrm_Contractor_Job_Detail].Form.Filter = "Inv_Pman_Prop_ID_WorkAt_Link =" & Me.Repair_Property_ID_Link And "Inv_Pman_Cont_ID_Link =" & Me.Repair_Contractor_ID_Link

I think everything is named correctly, should the above work or is the code not correct?

Thank you Mark
 
Hint:

Code:
Dim strFilter As String

strFilter = "Inv_Pman_Prop_ID_WorkAt_Link =" & Me.Repair_Property_ID_Link [highlight #FCE94F]And[/highlight] "Inv_Pman_Cont_ID_Link =" & Me.Repair_Contractor_ID_Link 

Debug.Print strFilter

Forms![frm_Contractor_Job]![Subfrm_Contractor_Job_Detail].Form.Filter = strFilter

Are [tt]Inv_Pman_Prop_ID_WorkAt_Link[/tt] and [tt]Inv_Pman_Cont_ID_Link[/tt] fields numbers or text?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Yes they are both numbers

This is what I have, but getting an error

Code:
Dim strFilter As String

strFilter = "Inv_Pman_Prop_ID_WorkAt_Link =" & Me.Repair_Property_ID_Link And "Inv_Pman_Cont_ID_Link =" & Me.Repair_Contractor_ID_Link

Debug.Print strFilter

Forms![frm_Contractor_Job]![Subfrm_Contractor_Job_Detail].Form.Filter = strFilter
Forms![frm_Contractor_Job]![Subfrm_Contractor_Job_Detail].Form.FilterOn = True
 
I would guess you have a Type mismatch error on line:[tt]
strFilter = "Inv_Pman_Pr...[/tt]
If so, that would be good to mention.

Code:
strFilter = "Inv_Pman_Prop_ID_WorkAt_Link = " & Me.Repair_Property_ID_Link[highlight #FCE94F] & " And[/highlight] Inv_Pman_Cont_ID_Link = " & Me.Repair_Contractor_ID_Link

Debug.Print strFilter

With Forms![frm_Contractor_Job]![Subfrm_Contractor_Job_Detail].Form
    .Filter = strFilter
    .FilterOn = True 
End With

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Thank you very much - all working :)
 
'Code not working'.

Wonderful term to enable people searching for a 'filter another form' solution - to find this particular issue.

*sigh*

Come on Moss - THINK ABOUT IT! ;-)
How about "Can't filter form from another form"?

ATB,

Darrylle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top