Duane
There's an awful lot going on in the query - I don't write code and am self
taught so to get the results we needed the process was a bit convoluted - I
have pared it down considerably but the results are still, unfortunately, the
same. That said, here it is:
SELECT CDate(IIf([Max Lease].[Lease Ends]+5>Date()-1,[Max Lease].[Lease
ends]+5,Date())) AS [Date Availalbe], [Max Lease].[Lease Begins], IIf([Max
Lease].[Lease Begins]>Date()-1,[Max Lease].[Lease Begins]," ") AS [Future
Lease Begins], IIf([Max Lease].[Lease Begins]>Date(),[Max Lease].[Lease
Ends]," ") AS [Future Lease Ends], [PN All status report as of today with
percentages].[Property ID], [PN All status report as of today with
percentages].[Currently Available], [PN All status report as of today with
percentages].[Lease Begins], [PN All status report as of today with
percentages].[Lease Ends], [PN All status report as of today with
percentages].Count, [Max Lease].Number
FROM ([PN All status report as of today with percentages] LEFT JOIN [Max
Lease] ON [PN All status report as of today with percentages].[Property ID] =
[Max Lease].[Property Id]) LEFT JOIN Tenants ON [Max Lease].[Tenant A] =
Tenants.[Tenant ID]
WHERE (((CDate(IIf([Max Lease].[Lease Ends]+5>Date()-1,[Max Lease].[Lease
ends]+5,Date()))) Between [start date] And [end date]))
ORDER BY CDate(IIf([Max Lease].[Lease Ends]+5>Date()-1,[Max Lease].[Lease
ends]+5,Date())), [PN All status report as of today with percentages].[Lease
Ends];
All help appreciated.
Bibi
Duane Hookom said:
Please provide more information like your full sql and any parameters.
--
Duane Hookom
Microsoft Access MVP
:
Duane,
Again, thank you but I am still not able to obtain consistent results for a
date range query - the result shows the correct month but for any year, not
just the year entered in the range....it does now sort by true date - it is
right aligned - I can only assume that there is a problem with the query
itself but we have tested it and have had no problems up to now. It is
formatted as a short date.
Any other suggestions?
Thank you.
Bibi
:
Does the Date Available column display left or right-aligned in the datasheet
view? If it is right aligned, it should accept a true date in the criteria.
Are you using a format of m/d/y?
You might simplify the expression a little with
Date Available: CDate(IIf([Max Lease].[Lease Ends]+4>Date(),[Max
Lease].[Lease ends]+5,Date()))
--
Duane Hookom
Microsoft Access MVP
:
Duane
Thank you for the prompt response. It did not work.... :-(
A criteria of Date()+whatever number does work - that is, it gives expected
results but when a date is entered as a criteria - - nothing. Any other
thoughts?
TIA
:
The IIf() function returns a variant data type. Try wrap your expression in
CDate()
Date Available: CDate(IIf([Max Lease].[Lease Ends]+5>Date()-1,
[Max Lease].[Lease ends]+5,Date()))
--
Duane Hookom
Microsoft Access MVP
:
I have a calculated field that calculates a date. It does not seem to retain
the date property. It sorts as text rather than a date – I have been able to
set the field property format to short date. It will sort by date if run
from the query screen. I need to be able to select a range of dates. Between
is not giving me the required results.
This is the field:
Date Available: IIf([Max Lease].[Lease Ends]+5>Date()-1,[Max Lease].[Lease
ends]+5,Date())
and the results are as expected. But I can not obtain range data no matter
what I try (I can't write code.) Please help!
TIA