473,408 Members | 2,535 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,408 software developers and data experts.

How to populate a field with result of calc???

3
So in a table I have a field that I want populated with the result of an arithmatic expression. For example, one field named VALUE, populated with a form, is a variable in an expression like VALUE * 132. I need to put the result in the same table with VALUE, in a field named RESULT. Is it possible to do this in the form with an expression or is the operation done in the table? I have attempted to write an expression as a calculated control in the form but I don't know how to write the expression to write the result to RESULT in the table.
Aug 2 '06 #1
4 1956
comteck
179 100+
You didn't say whether you wanted the RESULT to appear with the click of a button, or automatically as you scroll through. IT might work better with the click of a button. Here is how you do it. If you don't want it to happen at the click of a button, let me know.

I'm assuming the form's Record Source is the table with the RESULT field. On the form, create a textbox for RESULT. Make its Control Source the RESULT field.

Then create a command button. Right click on the button, and select "Build Event". Choose "Code Builder". Visual Basic will open, and the following code will appear:

Private Sub Command5_Click()

End Sub

You enter the required code in between the 2 lines. The final code should be:

Private Sub Command5_Click()
Me.Result = Me.Value * 132
End Sub

comteck
Aug 2 '06 #2
cpaul
3
Yes, thank you. Your assumptions are correct. I was hoping for a simple expression that would be defined in the properties dialog box for either the RESULT field in the form or the RESULT field in the table. This does look like a good solution. For the calculation to occur automatically, I think I would just use this code with the RESULT text box property of either "After Update" or "On Change". Got any input on that method?

Thanks Again.
Aug 2 '06 #3
comteck
179 100+
The "Me.RESULT=Me.Value * 132" would be the same code wherever you used it. You right click on the properties of the control, and scroll down to whichever event procedure you wish to use (i.e OnClick, OnCurrent, AfterUpdate, etc). Visual Basic will still open, and the first and last line of the sub will appear. You just put that line in between them.

You might want to play around with them and see which one works best for you.

comteck
Aug 2 '06 #4
cpaul
3
The "Me.RESULT=Me.Value * 132" would be the same code wherever you used it. You right click on the properties of the control, and scroll down to whichever event procedure you wish to use (i.e OnClick, OnCurrent, AfterUpdate, etc). Visual Basic will still open, and the first and last line of the sub will appear. You just put that line in between them.

You might want to play around with them and see which one works best for you.

comteck


Great feedback - very helpful. I am much obliged!!
Aug 4 '06 #5

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

Similar topics

8
by: Alistair | last post by:
this has been driving me nuts for over an hour now. I have a DB with a date field that is empty Because of this the records sometimes get included in searches because their contents are less...
3
by: Santosh | last post by:
Hi, I have a requirement in which, I need to capture a loan amount and the amount of down payment for that loan. According to the requirement, the user is going to enter enter the loan amount and...
3
by: MX1 | last post by:
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the...
3
by: Anonymous | last post by:
Hi all, I have a form people use to enter checking data. One of the fields is calculated based on finding the difference of two input fields on the form. Here are the fields: CheckAmount...
16
by: PeteCresswell | last post by:
I was happily coding along, putting some calculation results (rolling annualized rates of return - too compute-intensive to calculate on-the-fly - had tb staged beforehand via a batch job) into...
2
by: Dave McKie | last post by:
Hi all I am trying to Populate a combo box from a selection in an adjacent Listview. The Listview lists as a string the field names of 4 different fields in tblFile. So far I can populate the...
3
by: skinnybloke | last post by:
Hi - I have the following VB function within MS Access which is called via a query. How do I modify this code so that it will only do the replacement based upon the value of another field on the...
3
by: flickimp | last post by:
HI I have a database with one Main Table. That table has 4 Fields: Age Type Specialty Cost
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...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.