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

How to use a cmd button to change the order and filter for a subform

Status
Not open for further replies.

rew2009

Technical User
Apr 21, 2009
114
US
How to use a command button to change the order and filter for a subform. I have a Main Form and a subform within it and was able to make it look like a list box in Dataview. However, I could not figure out how to change the order or filter for the subform in the same way as I could do for the listbox. The subform is named "Update_Manager"

This is the type of code I used in the cmd button to change the order in the list box:

strSQL = "SELECT Query1QRY.ClientName,Query1QRY.Address, Query1QRY.Value FROM Query1QRY " & _
"WHERE Query1QRY.Value > 100000 " & _
" ORDER BY [Query1QRY].[ClientName] "

Me.List259.RowSource = strSQL

How would I change this code to work in the subform. Thanks
 
Have a look at the OrderBy and OrderByOn properties.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I think I know how to insert the "order by" and "filter" or "where" statements in the "select" statement but how to execute the ‘select’ statement in a command button in the main form to active a filter or order in a subform still alludes me.


Again, with your help I have pretty much mastered the select statements for a listbox. It can be executed thru the 'RowSource'statement by "Me.List259.RowSource = strSQL" where 'strSQL' contains the "select ...." and List259 is the list box. But what is the equivalent method for the subform. What would example code in the click event of the command button look like? Thanks
 
I think MajP may have the answer in my other thread, Thanks
 
rew2009 said:
[blue] . . . I have a Main Form and a [purple]subform[/purple] within it and was able to [purple]make it look like a list box[/purple] in Dataview.[/blue]
So! ... its a subform ... [blue]not a listbox![/blue]

So! ... we write the sql to the [blue]Record Source[/blue] property of the subform! forms don't have a [blue]Row Source[/blue] property.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top