Tags: access, assign, bound, database, field, form, microsoft, mysql, oracle, productcost, sql, subform, total, unbound, value, vistai

How to assign value of unbound field to a bound field in a form?

On Database » Microsoft Access

2,639 words with 3 Comments; publish: Fri, 04 Jan 2008 23:40:00 GMT; (25062.50, « »)

Hi,

I am using MS Access 2007/Vista

I have a field, ProductCost in the subform. i need to find the total of ProductCost and assign it to a field, Total, in the Main Form .

I read an article about how to find Sum from a subform field.

based on that, i stored the total value in an unbound field.

i dont know how to assign the value from the unbound field to a bound field , Total, in the main form.

can anyone help me in this regard,?

thanks

Kathy

All Comments

Leave a comment...

  • 3 Comments
    • Quote:
      === Original Words ===

      Hi,

      I am using MS Access 2007/Vista

      I have a field, ProductCost in the subform. i need to find the total of ProductCost and assign it to a field, Total, in the Main Form .

      I read an article about how to find Sum from a subform field.

      based on that, i stored the total value in an unbound field.

      i dont know how to assign the value from the unbound field to a bound field , Total, in the main form.

      Hi there!

      In subform's footer put an unbount control named SumProductCost. It's source property should be: =Sum(ProductCost)

      ...If I understood correctly you allready came this far.

      To show this total on the Main form put an unbound control named MainTotal in Main form's detail or footer section (if it's gonna be visible).

      In MainTotal's source property put: =Me!SubFormName.Form.SumProductCost

      I'll be here if you have more questions. Also you might try to read help in MSAccess, it's full of advices like this :-)

      h.

      #1; Fri, 04 Jan 2008 23:41:00 GMT
    • thanks for your reply.

      I can get the value in the main form unbound field.

      but i dunno how to store that value in to a bound field in a table...

      for example,

      i used the suggestion you gave me and i created an unbound field MainTotal

      it works like a charm.

      now, i wanted to assign the value in MainTotal unbound field into a field, TOTAL, in the main table.

      is it possible to acheive this?

      thanks in advance.

      luv,

      Kathy

      #2; Fri, 04 Jan 2008 23:42:00 GMT
    • hey Kathy

      Usually calculated values are not supposed to be stored in the tables because they can be allways recalculated. Anyway, if you wanna store that walue in the TOTAL field on your Main Form just add a code like this in your Sub Form's after update event:

      Code: ( text )

      1. Me.Recalc
      2. Me.Parent.TOTAL = Me.Parent.MainTotal

      After this Main Form will be in editing mode, and changes will not yet be saved so you can discard changes if you want.

      Best,

      h.

      #3; Fri, 04 Jan 2008 23:43:00 GMT