PDA

View Full Version : [SOLVED:] Updating a field values on a continuous form



Ettamucci
01-27-2016, 11:07 PM
Hi,

I am either totally out of my depth or am having a brain freeze but I need help with the following:

I have a Main Form (Recipes) with a continuous mode Subform (Recipe_Ingredients).
The main form has a few bound fields that are simply used to specify general things like name, sales price etc.

The Subform is used to select each ingredient in the Recipe and add 'Quantities'
The Ingredients field is a Combobox with 3 columns (Ingredient_ID, Ingredient_Name, Unit_Cost) with the record source from a query of the Ingredients Table.

Currently when I select an ingredient from the combobox i have code that uses the .Column(2) value and sets it to the 'Unit Cost' field (bound text box) on the same Continuous Subform.
I then keep adding as many ingredients as are needed to complete the Main Recipe. Each time I add an Ingredient, the SubForm calculates the Total Cost of each ingredient based on the Unit_Cost * Qty entered and then gives me a total recipe cost in the main form.

This all works perfectly and UNTIL i change the Unit Cost value of any ingredient in the Ingredients table.

If I then view my Recipes the Unit_Cost fields are not being updated.

I understand why this is happening, I just don't know how to get each row in the Subform to requery or refresh the .column(2) value from the ComboBox when the current record is viewed.

Do I have to code an onOpen event to open a recordset for each record in the subform and get the value this way? I just think this is too cumbersome and wondered if there is an easier way to requery this value.

Any help would be most appreciated.

Ettamucci
01-27-2016, 11:28 PM
Ok, brain freeze over, have it sorted.

It was so simple I feel totally stupid for even posting.

Simply added the set field value code again to the onCurrent event for the subform.