# Help with small result type

A

#### Alain

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
FROM (BasicRental LEFT JOIN tblTenant ON BasicRental.IdBranch =
tblTenant.IdBranch) LEFT JOIN Branch ON BasicRental.IdBranch = Branch.IdBranch
((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

D

#### Duane Hookom

Nz() returns a variant data type. If you want to ensure it is numeric, wrap
it in the Val() function.

BTW: I would have lots of trouble with a complex expression like you
created. Have you considered creating a small user-defined function that
accepts the basic fields/values and returns the appropriate numeric?

A

#### Alain

Thanks,
I am completly reworking this query into a much simpler way, I just found
out with some specific date it returns nothing at all so I guess it is way
too much complex for nothing

Thanks

Duane Hookom said:
Nz() returns a variant data type. If you want to ensure it is numeric, wrap
it in the Val() function.

BTW: I would have lots of trouble with a complex expression like you
created. Have you considered creating a small user-defined function that
accepts the basic fields/values and returns the appropriate numeric?

--
Duane Hookom
Microsoft Access MVP

Alain said:
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
FROM (BasicRental LEFT JOIN tblTenant ON BasicRental.IdBranch =
tblTenant.IdBranch) LEFT JOIN Branch ON BasicRental.IdBranch = Branch.IdBranch
((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