Thanks for responding. The queries are shown below.
As you can see, the first query is very simple and the second query is a
little more complex due to the Nz() function containing the listbox
reference and the nested IIf() function. The purpose of the IIf()
function is to make the query filter on the current fiscal year in the
event a fiscal year has not been selected in the lstFY listbox. Both
queries have been consistently returning the correct records.
Just now, I performed a test where I completely removed the filter from
the qryAppCodeLookup query and then re-ran my test. The problem went
away.
Afterwards, I modified the query filter by adding only the listbox
reference ([Forms]![ffrmWSDBgtToActByWBS]![lstFY]) and then re-ran my
test. The problem returned. The listbox reference appears to be the
source of the problem, but I don't know why. I'm guessing that the
problem may have something to do with the fact that a *listbox* control is
being directely referenced from Jet SQL.
As a workaround, I have a VBA function that I can use within Jet SQL that
will convert selected listbox items to a list that I can use within an
In() expression in Jet SQL. This alternative approach *might* solve the
problem.
If you have any other ideas please let me know. I'll post the results of
my next test as soon as I'm done.
qryFiscalYearLookup Query:
SELECT DISTINCT tblAppCode.FiscalYear
FROM tblAppCode
ORDER BY tblAppCode.FiscalYear DESC;
qryAppCodeLookup Query:
SELECT DISTINCT tblAppCode.AppCodeID, tblAppCode.AppCode,
tblAppCode.AppCodeDesc, tblAppCode.FiscalYear
FROM tblAppCode
WHERE
(((tblAppCode.FiscalYear)=Nz([Forms]![ffrmWSDBgtToActByWBS]![lstFY],IIf(Month(Date())>6
And Month(Date())<=12,Year(Date())+1,Year(Date())))))
ORDER BY tblAppCode.FiscalYear DESC , tblAppCode.AppCode;
xRoachx said:
Hey Mike, I tested what you posted using 2 list boxes but I was unable to
duplicate the issue. What are the underlying queries doing?