Simple Software Solutions
Bob is right in wha he is suggesting, I, however, use a different approach. The reason why is that the unerlying query is bound to that form and that form only. Lets say you want to run the same query from a different place in your database you would have to create a duplicate query but reference it to the new calling form. This is a bind as you need to constantly make sure that each version is identical if you make any changes.
Lets imagine you want to pass a date range to the query for filtering purposes.
First create two public variables within your startup module.
Public DteDateLower As Date
Public DteDateUpper As Date
Next Create two Functions
Public Function GetDateLower() As Date
GetDateLower = DteDateLower
End Function
Public Function GetDateUpper() As Date
GetDateUpper = DteDateUpper
End Function
In your query on the condition row underneath your filter date column enter:
Between GetDateLower() And GetDateUpper()
Finally, in a form, any form, the user will enter a date range for the filter on the AfterUpdate Event of each control enter the following code:
Private Sub TxtDateLower_AfterUpdate
DteDateLower = Me.ActiveControl
End Sub
Private Sub TxtDateUpper_AfterUpdate
DteDateUpper = Me.ActiveControl
End Sub
So when you run the query the two functions are called which then pass the date range to the query irrespective of where it is called from. You can do this with any type of field using any conditions.
CodeMaster:
http://www.icraftlimited.co.uk