First off my form just started working, and believe me I changed nothing in
my code. Perhaps I had a memory issue w/my system and re-opening cleared this.
Yes, sQry implies a query but it is just the contents of the where clause in
an SQL query. The year apparently is being cast as numeric and does not
require delimiter, although I'll try it that way so as to set the tone.
What I've learned: It appears that the DoCmd.Open report filter and where
components are both filters, the difference is lost on me, but I'm only using
the where clause and it's working now. Why it wasn't is also lost on me.
Most of the code was written by someone else, excepting for the use if
"where" in the OpenReport cmd. And yes, I should bracket or better yet not
use keywords. The year is ambigious anyway, it's actully the JobYear and
perhaps I should make it so; perhaps the novice that I'm assisting will be
able to get some better habits.
Originally my query did start w/1=1, which I use to be able to add "
and...." statements to in dynamic SQL in my sProcs. I may go back to that,
howver my form is accessing a query that already returns all records, but
I'll add it just the same.
Cheers, JeffP....
Duane Hookom said:
Jeff,
I think part of the issue is your use of "my query" in the following line:
If the selected manufacturer = "_All" first value in list, then my query
Also, the variable name "sQry" suggests a query rather than simply a where
condition.
The issue I see with your code is a missing quote following "else: sQry =
"Year= ...
Try
sQry = "1=1 "
If Not IsNull(Me.ddlYear) Then
sQry = sQry & " AND [Year]= " & Me.ddlYear
End If
If Nz(Me.ddlManu,"_All") <> "_All" Then
sQry = sQry & " AND Manufacturer = """ & _
Me.ddlManu & """ "
End If
DoCmd.OpenReport sReportName, acViewPreview, , sQry
--
Duane Hookom
Microsoft Access MVP
JeffP-> said:
On my snippyness, you mis-interpeted my notification, it was meant to advise
you nothing more.
Where: I havent included the keyword "where" in my DoCmd.Open report, should
I?
Perhaps I'm missing something, my understanding was that a filter is applied
after the data is returned and that the "where" clause was part of the
initial dataset creatation?