Using a Function as a Where clause

G

Guest

Hi guys,
I've got a fairly large number of queries that each refer to a particular
range of dates within their Where clause. To save time I thought I'd create
a Constant for the queries to refer to rather than have to change the range
of dates within each query every few months. Here's what I put:
Public Const conSeries As String = "Between #01/01/2005# And #05/02/2005#"
However, it appears you are not able to refer to a Constant within a query
so can you think of a better/different solution?
I've tried a function but this doesn't work either as the query does not
return any results.
I hope you can help!
Many thanks,
Lee
 
D

Duane Hookom

You can create public variables for datStart and datEnd. Then build a small
function that returns the values:

Public Function GetStartDate() as Date
GetStartDate = datStart
End Function
Public Function GetEndDate() as Date
GetEndDate = datEnd
End Function

Then your queries can use
Between GetStartDate() and GetEndDate()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top