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

applying filters to a subform

Status
Not open for further replies.

DavidCat

Programmer
Nov 19, 2000
10
AU
I have a mainform which has a couple of textboxes that are used to get data which builds a string. The string forms the criteria for a filter to be applied to a subform using the applyfilter method. The problem is how do I get it to apply to the subform? I tried to use the selectobject method to select the subform to apply the filter to, but it tells me I can't select the subform because it isn't open. And since I cant select it, I can't apply the filter to it.
 
You will have better luck with this method.
Create a SQL statement that has the textboxes in it.
You probably have it already in your filter you created.
Then set the subforms recordsource to that SQL string.

like so:

dim SQLstring as string
SQLstring = "Select * From yourTable Where somefield = " & me!Text1 & " And Someotherfield = " & me!Text2

me![subformname].form.recordsource = SQLstring

You can also make a temporary query to create the SQL string for you. In other words create a query that returns the records you want and then paste the SQL code it creates above.

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top