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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

applying subform filter to main form

Status
Not open for further replies.

parkfairfax

Programmer
May 22, 2001
63
US
I have 2 subforms; one is an author subform and the other is for keywords, both linked to the main form by record_id.

I would like to be able to type in a author or keyword on the search page that i am designing, and have the main form show all the forms limited to showing those with that author or keyword.

Can anyone give me any pointers? I'm stuck.
 
I am assuming that your 'search field' is an unbound text box... The code below should work to find search queries for the main form - then any subforms should refresh to show the appropriate values. So in your text box's after update event do something like this:

Me.RecordsetClone.FindFirst "[PrimaryField] = '" & Me!TextBoxName & "'"

If Me.RecordsetClone.NoMatch Then
MsgBox "No matching records found!", vbOKOnly, "Value Not Found"
Requery
Me!TextBoxName = ""
Me!TextBoxName.SetFocus
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
Me!TextBoxName = ""
Me!TextBoxName.SetFocus
End If

* Note: this is used for string searches - to search for numbers you would change the quotes around Me!TextBoxName:
'" & Me!TextBoxName & "'"


If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top