angelleye Posted July 10, 2007 Posted July 10, 2007 I've got a table called Parts. This table includes fields for Cost, QTY, and a field call IsCredit that gets 1 or 0 if the record is a credit to our account or not. The idea behind the check box is that if it's checked then the number in Cost needs to be negetive to reflect that in our actual cost of the item. So as it stands now I have the Cost field set to the following auto-enter by calc. If ( IsCredit = 1 ; Cost * (-1); Cost ) The problem I'm having is that the calc. doesn't fire but every OTHER check of that check box. For example... I have a record that I go ahead and check the box on. Then I fill in $5.00 for Cost and it correctly changes it to -$5.00 because IsCredit = 1. So far so good. Then, I simply uncheck the box expecting the -$5.00 to turn back into positive $5.00. this does not happen, though. It simply stays -5. If I then check the box again right after that it changes the -5 to 5, but now it's positive 5 when the box is checked which is wrong. I was under the impression that auto-enter by calc. would update anytime any of the fields involved changed. Is that correct? I've unchecked the "do not replace" option. So I don't understand why every other check of the IsCredit check box is switching the value of Cost..?? If it's checked IsCredit should equal 1, in which case Cost should be a neg. value. If it's not checked then IsCredit does not equal 1, in which case Cost should be a positive value. Any information on what i'm doing wrong here would be greatly appreciated. thanks!
comment Posted July 10, 2007 Posted July 10, 2007 Well, the second time you click the checkbox, it becomes 0. So the test IsCredit = 1 returns FALSE, and the result is Cost, i.e. no change in the current value. I think a better approach would be along the lines of: Case ( IsCredit ; - Abs ( Cost ) ; Abs ( Cost ) ) Note that this would prohibit negative credit - which could be desirable in some circumstances.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now