How to link unbound calculated control to created field in a table (1 Viewer)

Fandy

Member
Local time
Today, 18:01
Joined
Mar 26, 2021
Messages
37
I have a question. Please I have created unbound control on my form and i want to link to a already created field in
a table. How do I go about it? Can someone help me please?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:01
Joined
Oct 29, 2018
Messages
21,358
In the Form's Design View, select the unbound Control. In the Properties Window, select the Data Tab. In the Control Source property, select the created field from the dropdown. Hope that helps...
 

Fandy

Member
Local time
Today, 18:01
Joined
Mar 26, 2021
Messages
37
Thanks for the response but question is not answered. Let me re frame my question for better clarification. I've created a table and a form for it. On the form I have selected unbound control and put a formula in the control source. I thus want to link the calculated unbound control to one the already created fields in my table. I need directions to do this please. Thank you
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:01
Joined
Sep 21, 2011
Messages
14,046
In an event, perhaps Form's BeforeUpdate event
Code:
Me.FieldtoUpdate = Me.CalculatedControl

You need to change you names to suit?
Have your control to update hidden on the form and it's controlsource the table field
 

plog

Banishment Pending
Local time
Today, 13:01
Joined
May 11, 2011
Messages
11,611
On the form I have selected unbound control and put a formula in the control source. I thus want to link the calculated unbound control to one the already created fields in my table.

You don't usually store calculated values in a table, instead you either do the calculation as you have done on the Form/Report or you create a query that does the calculation and reference that query when you want the value.

Why do you need to store this value?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:01
Joined
Oct 29, 2018
Messages
21,358
Thanks for the response but question is not answered. Let me re frame my question for better clarification. I've created a table and a form for it. On the form I have selected unbound control and put a formula in the control source. I thus want to link the calculated unbound control to one the already created fields in my table. I need directions to do this please. Thank you
Also, can you show us the calculation/formula/expression? Thanks.
 

June7

AWF VIP
Local time
Today, 10:01
Joined
Mar 9, 2014
Messages
5,423
If field in table is a calculated field, there is no 'linking' necessary.

If field in table is not a calculated field and you want to save a value calculated on form, that requires code (macro or VBA). The code to save is simple, the real trick is figuring out what event(s) to put code into.

Usually calculated data should not be saved to table.

This is an extremely common topic.
 

Fandy

Member
Local time
Today, 18:01
Joined
Mar 26, 2021
Messages
37
My Form.JPG

The above is my form based on a created table. What i want to do is that, once i select the "Trans_Details", the associated
rate is displayed in the Service Rate box. I was finding it difficult so I used Dlookup formulae in an unbound control and i want
that unbound control to link to the Service Rate field in both Form and Table level. Need urgent direction please. Thank you.
 

Fandy

Member
Local time
Today, 18:01
Joined
Mar 26, 2021
Messages
37
In an event, perhaps Form's BeforeUpdate event
Code:
Me.FieldtoUpdate = Me.CalculatedControl

You need to change you names to suit?
Have your control to update hidden on the form and it's controlsource the table field
 

Fandy

Member
Local time
Today, 18:01
Joined
Mar 26, 2021
Messages
37
It worked bt partly. I see the change only after saving bt I want to see the change immediately after selection or entry.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:01
Joined
May 7, 2009
Messages
19,169
use the AfterUpdate event of Trans_Detail to assign the value.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:01
Joined
Feb 19, 2002
Messages
42,971
In reality, you should be using the Form's BeforeUpdate event to copy the calculation to the bound field if you are going to do it at all.

And let me add my agreement with the others. Doing this is almost certainly wrong. Storing calculated values violates second normal form. Always calculate values as close to when you use them as possible to ensure that they are up to date. When you store the value, you run the risk of one of the arguments changing and the calculation not being performed.
 

Users who are viewing this thread

Top Bottom