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
169 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

733 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