ms access - Calculated control does not recalc automatically -



ms access - Calculated control does not recalc automatically -

firstly, bit setup.

i have primitive database of 3 tables:

a. table lists various locations: [location_code], [location_name]

b. table describes items: [item_code], [item_name], [item_price]

and table ties roo^h^h^h whole database together

c. table says items stored @ each locations , in quantities: [location_code], [item_code], [item_quantity]. table can have multiple entries same [location_code], since different items can stored @ same location. basically, schoolbook implementation of one-to-many relationship locations items, attribute (quantity) attached each location-item link.

now, need create form list items stored @ location. basic use-case "subform" feature in access. main form navigates through different locations, while subform lists items.

i use

select c.location_code, b.item_name, b.item_code, b.item_price, c.item_quantity b inner bring together c on b.item_code=c.item_code

as record source subform. main form linked subform [location_code]. subform set list layout (not table layout), i.e. each database field given own command element.

so far works perfectly. select location in main form, , subform gives me list of editable [item_name]-[item_price]-[item_quantity] triplets current location.

as next step, want add together calculated command each of above triplets. want know total cost each kind of item (i.e. [item_price] * [item_quantity] in each line). easy, add together calculated command "repeatable" area of subform , specify

= [item_price] * [item_quantity]

as formula value. again, works perfectly. instead of above triplets, list has 4 entries per line: [item_name]-[item_price]-[item_quantity]-[total_item_price]. and, important, when edit [item_price] or [item_quantity], [total_item_price] gets automatically reevaluated 1 time finish editing.

and final step, want add together calculated command display total cost of items stored @ current location (let's phone call "grand total"). place command subform (into "footnote" area time) , specify next formula value

= sum([item_price] * [item_quantity])

now, works. total value calculated correctly each time alter location in main form. also, when alter [item_price] item @ current location, grand total updated automatically. however, when alter [item_quantity], grand total not update (???). hitting f9 create update. changing current location , forth update it. but, unfortunately, mere alter [item_quantity] not trigger automatic update.

does know, wrong here? why changes in [item_price] trigger automatic update of grand total, while changes in [item_quantity] not? intuitively, these fields seem have same status (except former comes table b, while latter comes table c). why behavior different? how create update automatically?

in subform's after update event, explicitly recalculate total cost control.

me.txttotalprice.requery

ms-access ms-access-2007

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -