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
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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