View Single Post
  #1  
Old May 21st, 2010, 02:17 PM posted to microsoft.public.access.queries
Alain
external usenet poster
 
Posts: 65
Default Help with small result type

Hi to all expert,

I am running kind of a complex query and I want to know why I get the result
as a string instead of a number/currency, the math is good :

SELECT BasicRental.IdBranch, Nz(Round(IIf(Nz(IIf(Eval([DateTo] Between
FirstOfMonth(DateAdd('m',1,Date())) And
EndOfMonth(DateAdd('m',1,Date()))),(([AnnualRental]/12)/DaysInMonth(DateAdd('m',1,Date())))*(DateDiff('d', FirstOfMonth(DateAdd('m',1,Date())),[DateTo])+1)),0)+Nz(IIf(Eval([DateFrom]
Between FirstOfMonth(DateAdd('m',1,Date())) And
EndOfMonth(DateAdd('m',1,Date()))),(([AnnualRental]/12)/DaysInMonth(DateAdd('m',1,Date())))*(DateDiff('d',[DateFrom],EndOfMonth(DateAdd('m',1,Date())))+1)),0)=0,[AnnualRental]/12,Nz(IIf(Eval([DateTo]
Between FirstOfMonth(DateAdd('m',1,Date())) And
EndOfMonth(DateAdd('m',1,Date()))),(([AnnualRental]/12)/DaysInMonth(DateAdd('m',1,Date())))*(DateDiff('d', FirstOfMonth(DateAdd('m',1,Date())),[DateTo])+1)),0)+Nz(IIf(Eval([DateFrom]
Between FirstOfMonth(DateAdd('m',1,Date())) And
EndOfMonth(DateAdd('m',1,Date()))),(([AnnualRental]/12)/DaysInMonth(DateAdd('m',1,Date())))*(DateDiff('d',[DateFrom],EndOfMonth(DateAdd('m',1,Date())))+1)),0)),2),0) AS Rent
FROM (BasicRental LEFT JOIN tblTenant ON BasicRental.IdBranch =
tblTenant.IdBranch) LEFT JOIN Branch ON BasicRental.IdBranch = Branch.IdBranch
WHERE (((BasicRental.DateFrom)=EndOfMonth(DateAdd('m',1 ,Date()))) AND
((BasicRental.DateTo)=FirstOfMonth(DateAdd('m',1, Date()))) AND
((Branch.Inactive)=False) AND ((Branch.RentRollChk)=False)) OR
(((Branch.Inactive)=False) AND ((Branch.RentRollChk)=False) AND
((BasicRental.MthToMth)=True))
ORDER BY BasicRental.IdBranch, BasicRental.SpaceNo, BasicRental.DateFrom;

My goal here is to cal rent for the following month and the rent need to be
based on the real amount of days in the month, meaning if my lease end the 20
of the month, the amount need to be prorated to 20 instead of 30 or 31.
I have been on this for the last few days .....

Anyway. my problem is why I get a string instead of a number ?
Any help will be greatfull