Solved

When a calculated field changes on a form, I want the value of another control to change as well. How do I do that?

Posted on 2011-03-24
4
167 Views
Last Modified: 2012-05-11
I need a field on a form to change to the same value when a certain calculated field changes value.
I need to store this value to act as a flag in another form.
Help please.
0
Comment
Question by:Fritz Paul
  • 2
  • 2
4 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 35205933
I assume you are talking about an calculated control on a form, not one of the new calculated field types in A2010.

You need to go back a step to do this.

If you have a calculated control, that control must be based on other fields and/or controls on the form or in the form's recordcource.  You need to add a line of code to the afterupdate event procedure of each of any editable 'source' controls.

The code would look like..

me.targetcontrolname = me.calculatedfieldname
0
 

Author Comment

by:Fritz Paul
ID: 35206311
Hi,
No this is not 2010.
Yes that is a solution, which I used on another form.
Took me ages to program each control. I was wondering if there wer not a solution like for the forms OnChange that if anything changes the value of the calculated field would update the bound field.
What I do now is that I added a close button and at least when I click the close button I set the bound control to the value of the calculated control.
Thanks for the help.
0
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 35208917
In general, Form events do not fire unless there is no available Control event which can fire first.

"What I do now is that I added a close button and at least when I click the close button I set the bound control to the value of the calculated control."

That seems very sensible as long as you don't need to see the changes as soon as they are made (which seems unlikely in this case- it sounds like you don't really need the bound field on the form at all). The more common route in VBA would be to use the Form_Beforeupdate event procedure to set the bound field value just as the record is being saved.
0
 

Author Comment

by:Fritz Paul
ID: 35209029
Thanks for the Beforeupdate event tip.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question