Requery subform w/ multiple queries?

  • Thread starter Thread starter Tom McMillion
  • Start date Start date
T

Tom McMillion

Good evening all,

I have a subform which was created from a select query.
The subform displays in Datasheet View a list of orders.
Once the status field of an order has changed from Queue
to Complete, that order drops off the list the next time
the end user clicks on a button which requeries the
subform.

I'd like to expand on this idea if possible to use a
second button to requery the subform BUT by applying a
different query or if you prefer an alteration of the
existing query from which the subform was created. Then
to be able to use the first button to once again requery
the subform using the criteria established in the
original query from which the subform was created.

That was a mouthful but does this sound doable through
VBA code? Perhaps converting the macro which requeries
the subform to code, and then altering the code? Then
copying that code to a second module associated with a
second command button, and editing the second module?

Note: I'm sure that what I want to do cannot be done
simply by filtering, because the select criteria within
the query determines which data to display on the
subform. I don't think a filter can do that.

Thanks in advance for any help and suggestions, which are
always appreciated.

Regards,
Tom McMillion
 
Tom, you can reassign the RecordSource property of the form to whatever SQL
statement you like:
Me.RecordSource = "SELECT ...

Be sure to save any changes first:
If Me.Dirty Then
Me.Dirty = False
End If

If you remove the critieria from the original form, and place the WHERE
clause into the Filter property of the form, it may be possible to do it by
simply altering the filters. Best to use this approach where you want the
user to be able to remove the filter completely, and reassign the
RecordSource if you don't want that to happen.
 
Back
Top