Adding Colums Error

byujakedmb

Registered User.
Local time
Today, 04:21
Joined
Jun 8, 2010
Messages
14
I've tried the following and none of them work..

1) LCHTotalInvestment: CCur((1.025*[ACPurchasePrice])+[WAI2]+[WAI3]+[WAI4])
2) [ACPurchasePrice])+[WAI2]+[WAI3]+[WAI4]

The values in the referenced columns are set as currency. What am I doing wrong?
 
What's the error? If any of the fields could be Null, you'd have to wrap them in the Nz() function.
 
What's the error? If any of the fields could be Null, you'd have to wrap them in the Nz() function.

When I run the query the result is #ERROR. How do I use the Nz() function
 
I think it's pretty well documented in Help. Check it out there and post back if you still have questions.
 
got it thanks!

I have a new problem now. The following formula returns the error "wrong number of arguments." Does that mean there is too much going on or does it mean I haven't structured the code right?

TotalAnnualizedReturnDollars: ccur(((1.025*(nz(ACpurchaseprice)))*(((((1.025*(nz(ACpurchaseprice)))/nz(lchtotalinvestment))*nz(netprofit))/(1.025*(nz(ACpurchaseprice))))*(365/(datediff(nz(purchasedate),nz(datesold))))))+((nz(WAI2))*(((((nz(WAI2))/nz(lchtotalinvestment))*nz(netprofit))/(nz(WAI2)))*(365/(datediff(nz(WAI2Date),nz(datesold))))))+((nz(WAI3))*(((((nz(WAI3))/nz(lchtotalinvestment))*nz(netprofit))/(nz(WAI3)))*(365/(datediff(nz(WAI3Date),nz(datesold))))))+((nz(WAI4))*(((((nz(WAI4))/nz(lchtotalinvestment))*nz(netprofit))/(nz(WAI4)))*(365/(datediff(nz(WAI4Date),nz(datesold)))))))
 
At a glance, the DateDiff functions are off. The first argument is the interval, which you've left out.
 
Ok so I added the interval into the datediff functions and now i get a #error.

TotalAnnualizedReturnDollars: ccur(((1.025*(nz(ACpurchaseprice)))*(((((1.025*(nz(ACpurchaseprice)))/nz(lchtotalinvestment))*nz(netprofit))/(1.025*(nz(ACpurchaseprice))))*(365/(datediff("d",nz(purchasedate),nz(datesold))))))+((nz(WAI2))*(((((nz(WAI2))/nz(lchtotalinvestment))*nz(netprofit))/(nz(WAI2)))*(365/(datediff("d",nz(WAI2Date),nz(datesold))))))+((nz(WAI3))*(((((nz(WAI3))/nz(lchtotalinvestment))*nz(netprofit))/(nz(WAI3)))*(365/(datediff("d",nz(WAI3Date),nz(datesold))))))+((nz(WAI4))*(((((nz(WAI4))/nz(lchtotalinvestment))*nz(netprofit))/(nz(WAI4)))*(365/(datediff("d",nz(WAI4Date),nz(datesold)))))))

Anyone know whats up?
 
Last edited:
The code is beginning to become unreadable. You will be able to spot your problem if you convert it to a Public Function in a module and call that function from the textbox's Control Source.
 
I figured out the problem. Thanks for your help! Also, sometimes i go to open up a query and a box pops up that asks me to enter parameter value for all of the attributes.. what is this and why does my query come up blank when I dont enter a parameter?
 
You may have renamed some field names or deleting some fields from the original table. Open up the query in DESIGN VIEW and check all the field names.
 
The fields did not change, but after re-entering the same field names it worked. Do you know why that could be? Also, how do I get the calculated value to show as a percentage in a query?
 
There's no disadvantage. If that query is solely for the form or you ALWAYS want to represent that value as a percentage and nothing else within your db then do it on the query level.
 
You also need to be thinking about using BODMAS Brackets Outside Multiplications, Additions & Subtractions. If you do not bracket you equasion correctly you will get some eird and wonderful answers.
 
Good point David.

I remember mentioning BODMAS to a poster once and they didn't get it :)
 

Users who are viewing this thread

Back
Top Bottom