473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Calculate fields on form open

I have created a MS Access form that is based on a table. There are some fields that are calculated in the form and populated on the table. Is there a way to recalcualte every record on the table when the form is opened?
Aug 28 '08 #1
4 2901
NeoPa
32,556 Expert Mod 16PB
It's a very bad idea to design the table so that it needs to be updated continually.

What you should be looking at is storing the base data in the table, then creating a query based on the table but which also includes the calculations you need.

The form should be driven by the query and not the table.

Does that help?

Welcome to Bytes!
Aug 28 '08 #2
Delerna
1,134 Expert 1GB
What, recalculate every record every time the form is opened?

To answer your question, yes, one way would be to write an update query to perform the calulated updates as you require. Then you run that query from vba in the Form_Load event for your form.

But I agree with Neopa, there is no need to store calculated fields.
Aug 28 '08 #3
missinglinq
3,532 Expert 2GB
With the exception of a few situations, calculated values should never be stored in a table, but rather re-calculated as needed. The fact that you want these values to be re-calculated every time the form opens indicated that this is npt one of those rare situations!

It would help us to help you if we had a more detailed explanation of what you're trying to do.

As a simple example, let's day TextboxC = TextboxA + TextboxB

One approach would be to have the Control Source set to the formula. In Design View for your form, select TextboxC then goto Properties - Date and in the Control Source Property enter

= [TextboxA] + [TextboxB]

You would have to do the same thing in order to include TextC in a report, using the same thing as the Control Source of an unbound textbox on the report.

Another approach, probably the better choice, would be to create a query on your table. In truth, because of issues just like this, most forms should be based on queries, even when only a single table is involved. Among other things, you can create a calculated field once, and it will be available to you, freom that pont forward, without having to re-calculate it again. Instead, the query automatically re-calculates it, every time the query runs.

In the Design Grid for the query, in a blank filed, you would enter something like:

CalculatedFieldC: [FieldA] + {FieldB]

With your form based on the query, simply assign the Control Source of TextboxC to the query's CalculatedFieldC. In a report, using this same query, you'd do the same thing.

Linq ;0)>

Sorry for the late post! Having connection problems today!
Aug 28 '08 #4
Thanks all for your help. I was able to create an update query that is kicked off by a macro when the form opens. It may not be the best way to do it, but it works.
Aug 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: carla | last post by:
I am using Access 2000 and have a table, tblCurrent. That table contains several fields - three of those fields are , and . What I want to accomplish in my data entry form, is first entering the...
1
by: oncewaswillow | last post by:
Hi, I have 3 nested forms and want to calculate a total on the first subform (as the form loads)by adding 2 fields from that form + to a field on the second subform. Second subform is and...
7
by: richard | last post by:
I have a table with 5 fields into which the user will enter numbers, which must add up to 100%. Say the fields are Toyotas, Missans, Mazdas, Hondas and Other. I am having trouble writing a query...
5
by: milan.letic | last post by:
Hello, I believe that this has been answered somewhere but I cannot find it. I have 51 textboxes on page. In 50 I can enter value. 51st should tell me what is average of entered numbers. As...
6
by: luanhoxung | last post by:
dear all!! i met the headache problem in setting value for some controls in my form. i have 2 combo box in form F1. i want to set value for some textbox in F1 when i choose value from 2 combo...
2
by: reidarT | last post by:
I have 3 fields in an aspx page. The 3. field should be the sum of field A and field B I use OnTextChanged to calculate the sum in field3. At the same time I want to insert the content of theese 3...
5
by: sara | last post by:
Hi - I have 2 new questions in a new database I'm trying to develop. The first has 6 fields on a table and allows the user to enter them on a form. The form is bound to the table. All 6...
2
by: martin77 | last post by:
Here is what I have for the code keep getting error on 'declare variables and assign address to object variables Dim strId As String, strPayment As String, curPayment As Currency ...
1
by: shivanee | last post by:
I am using 2 froms i.e salaryinfo is the main form, and salaryincrement is the subform. By selecting the empno i hv to enter his joining salary i.e.totalctc . If there is any increment then i hv to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.