473,379 Members | 1,252 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,379 software developers and data experts.

Not able to save data from a field in a form to a table.

I have a form with 2 fields. I use the first field to enter a number and if I enter this number, it saves me the number into the related field in the table. This works good. But in the second field I created a formula for this field, to count the number. It is using the number from the first field and multiplies it with another number. It works well because I can see the right number, but it is not saving that calculated number to the related field in the table.
Apr 29 '10 #1

✓ answered by missinglinq

My guess is that you have the formula in the Control Source of the wayward control, While this will display the calculation in the control, a control can only have one Control Source, hence it cannot be bound to the field in the underlying table.

To do this as you're asking you need to
  1. Change the Control Source of the 2nd control to the field in the underlying table
  2. Place your calculation in the AfterUpdate event of the first control, assigning it to the 2nd control (Me.SecondControlName = [Your calculation goes here])
Having said that, it is very seldom that calculations should be stored in tables! Instead, the calculation should simply be recalculated anytime you need it, whether in a form or a report.

Welcome to Bytes!

Linq ;0)>

Addendum: Jim's approach is also valid! In point of fact, I always base forms on queries, even if only one table is involved, for just the reason he gave.

6 2003
Jim Doherty
897 Expert 512MB
@Maris99
Welcome to Bytes :)

Is there any particular need to table store a calculated value?

I am not saying do NOT do it but generally you should not need to. My guess is that you do not know that a form can be based on a query.

Look at Access Help - 'Ways to perform calculation in a query' it is all documented

you will then understand that query can contain a 'formula' as an expression the advantages to you being that it becomes a usuable column in your dataset underlying the form. You only need bind the controlsource of the textbox to the column.

To help you I have attached a simple db take a look
Attached Files
File Type: zip simplecalc.zip (12.9 KB, 68 views)
Apr 30 '10 #2
missinglinq
3,532 Expert 2GB
My guess is that you have the formula in the Control Source of the wayward control, While this will display the calculation in the control, a control can only have one Control Source, hence it cannot be bound to the field in the underlying table.

To do this as you're asking you need to
  1. Change the Control Source of the 2nd control to the field in the underlying table
  2. Place your calculation in the AfterUpdate event of the first control, assigning it to the 2nd control (Me.SecondControlName = [Your calculation goes here])
Having said that, it is very seldom that calculations should be stored in tables! Instead, the calculation should simply be recalculated anytime you need it, whether in a form or a report.

Welcome to Bytes!

Linq ;0)>

Addendum: Jim's approach is also valid! In point of fact, I always base forms on queries, even if only one table is involved, for just the reason he gave.
Apr 30 '10 #3
Thanks guys both of the answers helped me a lot. Thanks again
Apr 30 '10 #4
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Apr 30 '10 #5
Alright so I am back once again:) Maybe its just me that I am dumb and not really skilled with access, but I tried to do it the way that I should set the after update field with the expression you wrote me(ofcourse I changed the names:)), but it keeps writing me out this: Microsoft office access can't find the macro `Me.`

Can you please explain it once again to me how should I change the first field to update the second one with the calculations.

Thanks a lot guys
Apr 30 '10 #6
missinglinq
3,532 Expert 2GB
You need to copy and then paste your exact code into a post so we can look at it.

Linq ;0)>
Apr 30 '10 #7

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

Similar topics

4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
11
by: deko | last post by:
I need to create different recordsets based on queries that use data from unbound fields in a form. I've discovered that I can't do this, and instead need to save the data in question (usually a...
2
by: crjunk | last post by:
I'm trying to write a piece of code that will programatically save a record automatically without me having to add a new ' Row.Item("ADD1") = txtAdd1.Text.Trim.ToUpper ' type command each time I...
3
by: kevin.vaughan | last post by:
Hello Everybody and Everymind, I am using Access 2003 on an XP network. The code below activates from a command button on a form. It selects data from a table and then displays it in a cell on...
0
by: amrhi | last post by:
Hy Guys , Can anybody help me ? I try to make small web database in my unit. Some of fields have on change behaviour to get other data that automatically filled other text field. But when i try to...
5
FOE2272
by: FOE2272 | last post by:
I have tried every option that I can think of and most of them on this forum. The closest that I got was to bring up the field but it changed the other records based on what was chosen in one...
6
by: subhashkumar | last post by:
Running data Append to a table Dear All, I need a help from this forum, I was developing a small tools for stock market. I get stuck when trying to save the running changes in a data field...
2
by: KC-Mass | last post by:
I have a form that is used to ID and then load Excel files into Access. I use labels on the form to record which file was last loaded. That was accomplished with a simple lblFileLoaded =...
5
by: terrybell105 | last post by:
I downloaded Stephan's utility from his website but can't get it to work - or maybe I'm not driving it properly! The form works OK with the existing 3 "views" - I can switch between them and they...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.