Hello,
I am currently in the process of switching some of our daily functions at the office from separate excel spreadsheets into a single Access database. So far I have this setup in form ("Contracts"):
Field A: total annual usage (kWh)
Field B: broker fee ($/kWh)
Field C: Anticipated Revenue (field A x field B)
Is there any way to have Field C automatically calculate when A & B are entered? The form is linked to a table. I've read a few different theories online but nothing seems straightforward, and if at all possible I would like to do it without manually running a query. Sorry if its a stupid question, I'm still learning Access - but this site had helped out immensely!
Any help would be greatly appreciated!
set field c's control source to:
=[fielda]*[fieldb]
15 2829
set field c's control source to:
=[fielda]*[fieldb]
Wow thank you so much! Can't believe it was that simple...worked like a charm! Thanks Again!
No problem.
Just for clarification. The value being displayed is only being displayed, not written anywhere.
hmmmmm... is there anyway to store that data in the table that the field is linked to? If that's not possible I guess my only other concern would be whether or not I would be able to run a query that can total those amounts from all of the forms. Any thoughts?
As background info, by changing the fields control source you've 'unlinked' that form field from the table. This only affects this one field.
In general, you usually don't need to store values that can be derived as in this case.
If you need a way to view the total from all of the records behind the form, then you just need a query with a field that is:
[fielda]*[fieldb]
It would look something like this:
SELECT ([fielda]*[fieldb]) as AntRev
FROM yoursourcetable
Obviously you'll have to change the table and field references to match your table, but that should do it.
Awesome, got that to work as well. Thanks again.
As a side question, what in your opinion would be the best way to view the sum of the AntRev column? Would this be possible on a report?
If you named you last query 'Query1' - SELECT Sum([AntRev])
-
From Query1
Then you can set the control source of a report field to this new query field.
If you don't actually need to print it out, you can simply add a field in your form footer with a control source of: - =DSUM("[AntRev]","YourTableName")
Wow, thank again! Worked just as described. However I do have (hopefully) one last question -
Another column in the table is for Sales Rep, which is a simple combo box linked to a table with the sales rep's names as separate records. I would like to be able to have a criteria of sorts that would show me the sum of the AntRev, but only for a specific sales rep. I tried to put a parameter on the sum query you just laid out for me but it gave an error saying I was trying to execute a function that includes a field that is not part of the aggregate function.
I don't even know where to begin to put that one together. Again you've been a huge help and your responses are greatly appreciated. This site is truly amazing...
If somewhere in the table with the revenue data, there is a field with some sort of reference to the agent then it's simply a matter of adding the agent table to the original query and joining them on the related fields.
I'm not quite sure what you mean by "joining them on the related fields"... I have attached a photo of the original AntRev query (not the sum query) in design view with how it is currently set up. (Although the Rep table is showing at the top none of the fields have been added to the query.)
Ok, you have them joined. Just add the RepName field from either one of the tables in the query. In the 'criteria' line of the RepName field, add [Enter RepName]
Every time you run the query, it will ask you for the rep name
Thanks, I can get that to work for the AntRev query...however when I try and apply the same method to the
SELECT Sum([AnticipatedRevenue]) AS [Total Revenue]
FROM AntRevQuery;
it gives me the error message I mentioned. I can't even think of the schematics of how it would be laid out because the sum query only returns a single cell with the amount in it, but like I said I'm an amateur . Thanks again for the replies!
It shouldn't error. If the sum query is based on the AntRev query then then sum query should also ask you for the agent
Wow, unreal...works like a charm. Thank you so much, you have no idea how much you've helped. Awesome!!
I just looked at the picture you sent. You need to ask for the name in the AntRev Query only. You can take the contracts and Rep table out of the sum query all together.
When you build a query on top of another query with a parameter prompt, you will still be asked for the parameter because the query on top can't return results until the lower level query parameter is input.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mail2atulmehta |
last post by:
Hi,
I do not know if this is right place for this, but i need some help. I
have a text file, whose values are seprated by a delimiter. I want to
open this file in excel, ( not import it) . I have...
|
by: Asaf |
last post by:
Hi,
I have a mixed text Hebrew/English and I would like to reorder just the
English text.
I was reading that this task can be done with GetCharacterPlacement API
function but I don’t know how...
|
by: Sridhar |
last post by:
Hi,
I have a export to excel function where it exports the data of a datagrid
into the excel sheet. For this, I am using the button and the text on that
button reads "Export to Excel". Instead...
|
by: jobxyz |
last post by:
Hi
I am trying to call the excel function linest from VB using automation.
the call
Slope1 =
Excel.WorksheetFunction.Index(Excel.WorksheetFunction.LinEst(y, x),1)
works fine as long as x...
|
by: Jaime Leivers |
last post by:
Here's a median function in access that you can call in any query. You
could change this to any excel function you wanted. Most people can
find the windows help file that says how to call an excel...
|
by: Vibhu |
last post by:
If a website is developed using ASPX, the page is submitted using the
Javascript function
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
I am building a small application that...
|
by: staeri |
last post by:
I have a gridview which calculates a value in a templatecolumn. I want
to save the calculated value into the database when all the other data
is saved. How can I do that?
As it is now I don't...
|
by: Prashantsd |
last post by:
Hi,
I have problem storing the calculated value in table.
I have a text box(Ranking) which display the sum of 4 combo box.
this is wat I hav done in control source of tex box = + + +
I...
|
by: chisty |
last post by:
can any one tell how to write a text file inputs to different edit boxes using a button.....text file contain different data.displaying each data in different edit boxes using single button click
|
by: mlcampeau |
last post by:
I have a report (JobVacanciesOnly) that has a subreport (JobVacanciesOnlySR) that are based on two separate queries.
MY - JobVacancyJobs
SELECT Job.Code, Job.Title, Job.Grade, Grade.Minimum,...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |