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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now