> >I have code that works already, with the exception of a date range. In the
> > database there is a field named BarDate that I want to run a query on. My
[quoted text clipped - 72 lines]
> like:
> http://www.members.shaw.ca/AlbertKallal/ridesrpt/ridesrpt.html
> Sweet!
> Just had to make a few changes and it works like a champ!
> How does this exactly build the criteria...it works great, but could you
> give me some insight as how it builds?
It works exaclty the same way your oringal code works. We simply build up a
string that is the resuling filter.
dim strtest as string
strTest = "hello"
msgbox strTest
messbox is = Hello
strTest = strTest & " how are you"
msgbox strTest
msssbox is = Hello how are you
So, you can just "string" (pun intended) togher each part of the filter
string.
we got somting called strSql:
strWhere = ("City = 'edmonton'")
gosub addWhere
now, strSql = "(City = 'Edmonton'")
strWhere = "(SalesRep = 'Albert'")
gosub addWhere
now strSql = "(City = 'Edmonton') and (SalesRep = 'Albert')"
So, each time we call gosub addWhere, we are simply adding on the next
filter part. We build this up by EACH clause into that string. And, if you
leave the contorl bank, then we don't bother to "set", or add the certiea
(no need to add the salesrep to the condstions if it is blank). I mean, if I
leave out sales rep aobve, then we just filter by the city...
If you want to see how this works step by step, then just add the follwing
line of code (to be removed later asfter testing)
addWhere:
if strSQL <> "" then
strSQL = strSQL & " and "
end if
strSQL = strSQL & strWhere
msgbox "new add condistion = " & strWhere & vbcrlf & _
"result = " & strSQL
return
So, just add the above and then run the code, you will easlity see how this
works

Signature
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal