I have an unbound form for calculating costs of a product and what we should charge. There are several calculated controls such as yields and totals. I have entered the calculation formulas in the control source of the txtBox. All the other fields with data that goes into the calculations get their info from queries. However, I want to do "what if" scenarios and change the numbers in the controls that get their data from a query (overwriting the default numbers) and then have the calculated fields show the new results based on my input directly on the form. I then want to be able to save all the "input" data whether it comes from a query as a default, or my input as a scenario into a table.
How do I get the calculated fields to update after I put new information into the other fields. I want the entire form to update when I put in a new value in any one box so I can see how the scenario progresses. (The "Calculate" button on the form may not be necessary ?)
On the screenshot, the red fields are calculated. All the others will come from a query or direct input, but I need to be able to put new numbers in any of the black ones and have the red ones recalculate.
I also want guidance on storing the fields that contain variable data to a table and then retrieving it back into the form as a saved "scenario". I will need to put more combo controls on the form to choose the saved scenario for editing.
The accepted answer will deal with all of the above issues. Thanks in advance, Greg
You can try using Me.ReCalc, but I'm not sure if that works on an unbound form. If not, you might be able to connect a dummy table to the form so that it is bound.
Otherwise, you will have to call code that does the calcs for each control and set the values.
I have found my own answer and it is; Use the cbo box to select the product. Then After_Update, do a dlookup on each field that needs to be populated with Me.txtxxxxx = dlookup(). Save the required fields out to a separate table that stores the scenario data. The calculated fields will automatically update when new data is put in an empty txt box.