K
katsup
I’ve created a simple macro that uses the SetValue action to store a
calculated value in the underlying table of a form control.
It works, pushing the calculated value into the tablefield as necessary,
but with an admonitory error message popping up as I tab to different
controls in the form. I’d like to eliminate the nagging.
(I realize I’ve waded into design-discussion-territory here by storing
calculated values in a table, i.e., wasting space and compromising historical
data, but I’ve decided to go ahead anyway with one calculated field in one
small table of the db.)
Here’s the macro:
- - -MacroName- - - -Action-
macSHCalculatedTotal SetValue
SetValue
Item: [SHCashPurchaseTotal]
Expression: CCur([SHProductUnitPrice]*[SHQuantityPurchased])
I’ve set the OnCurrent property of the form to macSHCalculatedTotal, along
with the AfterUpdate properties of the SHProductUnitPrice and
SHQuantityPurchased bound controls.
The form opens fine, but when I go to append a new record I get an “Invalid
use of Null†diagnostic, upon which I close the nag, oops, diagnostic,
window, and an “Action Failed†diagnostic on my macro appears, its Condition
showing as True, and only the “Halt†button available. Clicking “Halt†allows
me to proceed choosing a product id in my form, and key a number in the
Quantity field, but when I click the unit price field to fill it in, Null nag
neighs at me again. (Sorry, couldn’t resist…). Close the nag and Halt the
“Action Failed†diagnostic a second time, and the calculated total finally
appears. Checking the underlying table shows it’s being updated correctly.
I’m suspecting Access doesn’t like trying to execute the macro on the blank
fields in a new record, but what’s the solution?
calculated value in the underlying table of a form control.
It works, pushing the calculated value into the tablefield as necessary,
but with an admonitory error message popping up as I tab to different
controls in the form. I’d like to eliminate the nagging.
(I realize I’ve waded into design-discussion-territory here by storing
calculated values in a table, i.e., wasting space and compromising historical
data, but I’ve decided to go ahead anyway with one calculated field in one
small table of the db.)
Here’s the macro:
- - -MacroName- - - -Action-
macSHCalculatedTotal SetValue
SetValue
Item: [SHCashPurchaseTotal]
Expression: CCur([SHProductUnitPrice]*[SHQuantityPurchased])
I’ve set the OnCurrent property of the form to macSHCalculatedTotal, along
with the AfterUpdate properties of the SHProductUnitPrice and
SHQuantityPurchased bound controls.
The form opens fine, but when I go to append a new record I get an “Invalid
use of Null†diagnostic, upon which I close the nag, oops, diagnostic,
window, and an “Action Failed†diagnostic on my macro appears, its Condition
showing as True, and only the “Halt†button available. Clicking “Halt†allows
me to proceed choosing a product id in my form, and key a number in the
Quantity field, but when I click the unit price field to fill it in, Null nag
neighs at me again. (Sorry, couldn’t resist…). Close the nag and Halt the
“Action Failed†diagnostic a second time, and the calculated total finally
appears. Checking the underlying table shows it’s being updated correctly.
I’m suspecting Access doesn’t like trying to execute the macro on the blank
fields in a new record, but what’s the solution?