baadams
Board Regular
- Joined
- Mar 2, 2006
- Messages
- 134
I've searched and found close solutions but nothing exact.
I've got a form with search criteria in the header. The detail of the form has another form that is based on a query that used the fields in the form header as the criteria. So each time the criteria is changed the query and form are refreshed. This works fine but the format is somewhat rigid. This is a customer requirement that the header have the search criteria and the detail be in datasheet view. So it can be edited.
Let’s say I have 3 criteria for viewing vehicles. Model, Type, Color. Currently you can choose a Model, Type and Color and it works fine. But if you want to just search by Model, I have to create a different query. The current query requires all three fields to be populated. This is easily done with SQL. The SQL select and sort will always be the same. The only difference is the where clause.
My question is how do I use VBA to change the record source of the form within the detail of the current form? (I understand this may not be the best design but the customer wants the result in datasheet view while still having the search criteria available in the header. Otherwise I would just filter the form in datasheet view but the header isn't available) I know the SQL but any effort to change the record source ends in an error. I've got a list box on another form where I change the row source based on SQL and it works great. This seems somewhat similar but I can't get it to work. Thanks for the help.
I've got a form with search criteria in the header. The detail of the form has another form that is based on a query that used the fields in the form header as the criteria. So each time the criteria is changed the query and form are refreshed. This works fine but the format is somewhat rigid. This is a customer requirement that the header have the search criteria and the detail be in datasheet view. So it can be edited.
Let’s say I have 3 criteria for viewing vehicles. Model, Type, Color. Currently you can choose a Model, Type and Color and it works fine. But if you want to just search by Model, I have to create a different query. The current query requires all three fields to be populated. This is easily done with SQL. The SQL select and sort will always be the same. The only difference is the where clause.
My question is how do I use VBA to change the record source of the form within the detail of the current form? (I understand this may not be the best design but the customer wants the result in datasheet view while still having the search criteria available in the header. Otherwise I would just filter the form in datasheet view but the header isn't available) I know the SQL but any effort to change the record source ends in an error. I've got a list box on another form where I change the row source based on SQL and it works great. This seems somewhat similar but I can't get it to work. Thanks for the help.