Refer To Previous Calculated Field

Jan 17, 2007

Access 2003.
I was just wondering if there was any way to refer to a calculated field in the same query.
For example if the first calculated field was - Total: ([Quantity])*([Price]), could you add another calculated field - Inc Tax: ([Total])*1.175.
At present I am having to type the whole formula in the calculated field again which seems to work for some queries, but not for others, no matter how I fiddle about with the syntax. The other way is to create another query and refer to my previous query. Both these methods seem extremely cumbersome and I was wondering if I have missed something with referring to a prior calculated field.
The query above is just an example, my query formulas are actually fairly long and for editing purposes it can be difficult to correct them.

View Replies


ADVERTISEMENT

Calculated Field Utilising Data From Previous Record

Sep 14, 2004

Somebody please help me!!!

I am creating a database that will record the details of approx 30 shops and will store information on Annual Turnover, Profit, Return, etc.

I need to create a field that will calculate the increase/decrease in annual turnover between the current year and the previous year.

So far I have created a subform that will show the last 12 years of data for the particular shop, but now I need to add a calculated field that will get the current years turnover and also reference the turnover for the previous year, i.e. the previous record., and display the result. The other thing that I will need to do, is to have this field not calculated for the initial years trading, so this field will need to be hidden in the first record.

Can someone please offer some advice on how to go about achieving this???

View 1 Replies View Related

Having A Records Calculated Field Get Info From Previous Record

Jan 20, 2007

I have a table (tblStats). The user enters his current weight in a field named Wt. There are 2 other fields in the table named WkLoss and TTDLoss. These two fields are intended to be calculated. What I am trying to do is when the user enters his current weekly weight figure into the Wt field, I want the field WkLoss to get the user's weight from the previous record and place the difference in the field WkLoss. Also I would like to keep a total to date in the TTDLoss field.

So far this has been my attempt.
Code:Public Sub setWeight()Dim rs As DAO.RecordsetDim Startval As DoubleStartval = 190Set rs = CurrentDb.OpenRecordset("tblStats")'Select records to be updatedSet rs = CurrentDb.OpenRecordset _("SELECT * FROM tblStats ") rs.MoveFirst Do rs.Edit'field to update rs.Fields("WkLoss") = Startval rs.Update rs.MoveNext'increment step value Startval = WkLoss - Wt Loop Until rs.EOF rs.Close Set rs = Nothing End Sub
All I get is the value 190 placed in the first record and all zeros in the subsequent records. Also I don't have a clue as to how to get the Total To Date field to calculate.

Any help would be appreciated
Thanks for your time.

View 1 Replies View Related

Queries :: Refer To Previous Record In A Query

Mar 29, 2015

I'm trying to refer to previous record in a query and i'm stuck as i do not know how to do it.

Here is my query:

Code:
SELECT
[Prod2Buy].[Product Code],
IIF([Missing] IS NULL,0,[Prod2Buy].[Quantity To Order]-[To Order]) AS [Rest To Order],
s.s_manu_code AS [Manufacturer Code],
s.prod_cost AS [Price Code],

[Code] ....

In fact the line: IIF([Missing] IS NULL,0,[Prod2Buy].[Quantity To Order]-[To Order]) AS [Rest To Order] should refer to previous record.

View 9 Replies View Related

Queries :: Average Calculated Field From A Previous Query - Crosstab Data Type Mismatch

Jun 3, 2014

I am trying to construct a crosstab that averages a calculated field from a previous query. It is returning a "Data Type Mismatch" message.

The field I am trying to average is a subtraction of dates to find total days. I assume my field is not a number so I have tried to wrap it in CDbl() to change the type.

The formula is

Code:
CASE_DAYS: CDbl(IIf([Actual Close Date]-[Creation Date]>=0,[Actual Close Date]-[Creation Date],""))

View 5 Replies View Related

Forms :: Refer To A Calculated Value In Unbound Control In A Form

Jul 19, 2015

In my DB i would like to make a form that displays different calculated values based on other forms and queries like income running cost etc., but i do not know how to refer in an unbound control to value of a control in another form. I get always #names? error. However it worked when loaded that form i refered to. Is there a way to do it without loading the refered form?

View 3 Replies View Related

Refer To Previous Record In Current Record Query

Sep 15, 2005

In my query, i want to automatically display the value of another field from the previous record in a field in my current record. i.e.

Name Value Previous
Record 1 1
Record 2 2 1
Record 3 7 2
Record 4 1 7

Is it possible to create some kind of simple expression to refer to data in another record?

Cheers,
Ben

View 6 Replies View Related

Query Design To Produce Calculated Value Using Previous Record Value

Jan 28, 2013

I would like to build a query that has a calculated field, involving value from a previous record. I have five columns, Year (sorted ascending), InvestmentRate, StartingBalance, AnnualContribution, and InterestIncome.

The first row, being the smallest year value, uses a previously defined elsewhere starting balance, annual contribution, and interest income. This is recognized via an Iif statement and establishing the first set of values which the second row should use to calculate.

The second record, and until the end of the query, automatically calculates the new starting balance value based on the sum previous row record's starting balance, annual contribution, and interest income.

Furthermore, for the second record, and untill the end of the query, the InterestIncome is calculated value incorporating the second row's StartingBalance value (which is the product of the sum of the previous record's values).

This calculated referencing to the previous record is causing difficulties.

View 2 Replies View Related

Form With If Refer To A Value In A Field

Feb 13, 2005

Hi All!

Well I got a problem and guessing this is possible to do like this but well after few hours and staying at the same point maybe some help can be greet

I have a database witch I have 2 important field and a command for this. A field called ID with a number and another called GenerationID who contain number between 1 to 12 depending of which generation is. I got this Generation ID from a subform. What I want is this:

Depending of the number in generationID field show a different button like ID3 with generationID = 3 or ID2 if generationID = 2 etc until 12 and then other command buttn is not visible.

I don t know how to put the code but the code probably look at this:

If generationID = 3 Then
ID1.Visible = False
ID2.Visible = False
ID3.Visible = True
Else If
generationID = 2 Then
ID1.Visible = False
ID2.Visible = True
Id3.Visible = False
End If
End If

or if you have a better way all is welcome.

View 4 Replies View Related

General :: Refer Field In SubReport Which Is In Report Footer

Nov 21, 2013

I want to refer field "plyty_sa" which is in "RaportZleceniaRobocze" Report, in "RaportRobocze_Offset" SubReport. The problem is that, SubReport is in Report Footer. I tried many possibilities but I can't find solution.

View 1 Replies View Related

Basing A Calculated Field On Another Calculated Field

Apr 12, 2006

My query contains two calculated fields [TaxSavings1] and [TaxSavings2], which are based on some currency and number-type fields in one of my underlying tables.

I just created another field in my query which looks like: [TaxSavings1]+[TaxSavings2]. Instead of adding the two fields, it actually lumps the two numbers together. For example, if [TaxSavings1] =135 and [TaxSavings2]=30.25, it will give me: 13530.25. I need it just to simply add, i.e. answer of 165.25.

Does anyone know how to correct this? Thanks in advance.

:confused:

View 1 Replies View Related

Forms :: Can A Field Auto-fill From Previous Entry In Separate Field

Mar 21, 2013

I've just returned to work after kids and started managing a large Access database related to health, back-tracking over many years.

Currently in filling a form we physically enter:
Apples 2.2
red apple 2.4
red apple cut 2.45
Oranges 5.6
Cucumbers 8.5

Is it possible to get field 2 to automatically fill with a number code due to the text typed in field 1?

FWIW, I'm confident at more basic Access e.g making follow on default value = Dlast("field""table") type stuff but the more complex stuff I haven't touched since Uni over a decade ago and you will need to be gentle while I blow away the cobwebs

View 3 Replies View Related

Forms :: Autofill Field Based On Related Field In Previous Form

Jun 30, 2015

I have my Assets form and the primary key is the ChargerID, in this form I have an "Add New Job For This Asset" button, which opens up the Jobs form at a new record.

How do I make it so that the ChargerID field is automatically filled with whatever the previous record was instead of being blank.

For example if I have Charger12345 open in the Asset form, I'd like to click the Add New Job button and it automatically have Charger12345 in the ChargerID field of the Jobs form.

View 5 Replies View Related

Calculating Field Based On Value Of Another Field In Previous Record

Sep 18, 2014

I'm trying to create something like an online banking view that shows the running balance as each transaction occurs. I have tblTransactions with fields AccountNumber, ItemDescription, and TransactionAmount. I'm trying to create something that shows these three fields and a fourth field with the running balance.

So if I initially deposit $100 it will show the first record with TransactionAmount = $100 and RunningBalance = $100. Then the next transaction will subtract the Transactionamount for the new record from the RunningBalance from the previous record to get the RunningBalance for the new record. So if I make a purchase for $2, the AvailableBalance for that record is $98. Is this possible with a query? Here's a picture to describe what I'm talking about ....

View 3 Replies View Related

Showing Field Dependent On Previous Field In A Form?

Oct 24, 2012

I have a table called welding, I want to create a user friendly form for input. The database ultimately wants to go on share point so I am building it in the web database option.

One of the fields is called location, if the location is 'Field' I want 10 more fields to appear for data entry such as weld reason, rail temperature etc . If the location is 'Depot' I want these fields to be hidden as they aren't relevant.how would I do this?

View 14 Replies View Related

Tables :: How To Make Calculated Field Based On Field In Another Table

Jun 18, 2014

Table1 contain Two fields (3Months) and (6Months)

Table2 contain Two fields (3Months) and (6Months)

the table 2 is the source of a form that will let the user change the numbers. table 1 should change Date1 and Date2 Fields based on the two fields (3months) and (6months) if i want to make a lookup wizard it should be changed manually and if i make a calculated field i can't find other tables in the expression builder

View 1 Replies View Related

Queries :: Calculated Field To Display Value Of One Field Based On Another

Jul 23, 2015

I have a query with a Date field for EndDate (the dates for end-of-week, Fridays in our case) and another field for Sales (number of sales, not dollars).I want to add 4 calculated fields that represent weeks and have the Sales appear in the correct column (field) for that date.So I will have columns for 10 July 15, 17 July 15, 24 July 15 and 31 July 15 and I want the Sales for each record to land in the correct date column, based on the EndDate column. (The 4 fields is just for the sake of the example, I will actually be having dozens of these calculated date fields).I tried to do it by setting up the 4 calculated fields like:

10Jul15: Sales
and then adding Criteria like:
EndDate = #10/07/2015#
It doesnt work.

View 3 Replies View Related

Tables :: Calculated Field Error - Cannot Define Field More Than Once

Jun 10, 2015

I use access 2010.

I am assuming by the error code, one can not use a calculated field to calculate another field.

View 1 Replies View Related

Field Value Same As Previous Record

May 23, 2006

When I click my command button that says, "New Record", I want it to go to go to a new record and populate the field "Town" with the value in the previous record.

e.g. ClientID on last record is 150 and has Town="London". Click "New Record". New record created. Town field on ClientID 151 has Town="London".

How can I do this?

Thanks,

Dave

View 3 Replies View Related

Default Value From Previous Entry Into Field

Apr 4, 2008

Hi,

I have a user who would like the value from the last entry into the form's title field text box to show as the default value when he clicks on enter new issue button to bring up a new record. I do not know if this is possible but I thought I would check for him.

View 14 Replies View Related

Get Previous Field Value In A Query Without A Form

Aug 20, 2005

I have been looking at some of the solutions to the running sum problem.

The queries I use cannot use the primary key as there are gaps as some filtering has been done with an unmatched query to give me my sample dataset.

From this dataset I have a list of courses and the number of learning hours per each course. This is the field I would like to perform the running sum on.

Its a parameter query and the intention is to email the query the the various schools so no form was necessary.

The solution on microsofts web site wants me to use a form and I dont understand how it works anyway.

Is there a code solution that can use a recordset that doesnt rely on forms?

At present I am reliant on the date which does work but not where a student does two courses on the same day. The forums advice was to use the autonumber but there are gaps in that so that doesnt work. can I generate an autonumber on the fly as an expression and use that in the sub query method?
Fields:
[Date][Person Id][Course Code]
[Course Name][GLH][Running Total][UpliftCode]
[50%][Rule Broken]

what I have so far:

SELECT Pro.Date, Pro.[Person Id], Pro.[Course Code], Pro.[Course Name], Pro.GLH, (Select Sum(Pro1.[GLH]) FROM [QryAllEnrolmentsWithoutMatchingQryWithdrawls] Pro1 WHERE Pro1.[Date]<=Pro.[Date]) AS [Running Total], Pro.UpliftCode, [Running Total]/2 AS [50%], IIf([UpliftCode]="99","No",IIf([GLH]>[50%],"N","Y")) AS [Rule Broken]
FROM QryAllEnrolmentsWithoutMatchingQryWithdrawls AS Pro
ORDER BY Pro.Date;


kind regards in advance

View 1 Replies View Related

How To Retrieve Field From Previous Record?

Sep 8, 2006

Okay, here's the query as simplified as possible:



Month - Days - PreviousMonth



Month and Days are pulled from a table called Calendar. How do I get PreviousMonth to display the Month from the previous record?

I was looking at a ranking formula, and it seems like it compares the field to the previous one, but I am not sure how to apply it to my situation. The ranking formula I was looking at:

(Select Count(*) from Data Where [ProductA1] > [Data1].[ProductA1];)+1



Thanks in advance for the help.

View 3 Replies View Related

Autofill Field Based On Previous Value

Dec 27, 2005

I am trying to autofill a field based on the value of a previous field on a filtered form. I think the fact the records are filtered is throwing me off. Any help for me?

View 9 Replies View Related

Copying One Field From The Previous Record

Mar 1, 2007

Is there a way to make a button on a form that when it is pushed it copies one field from the previous record and then the rest is blank?

View 1 Replies View Related

General :: How To Use A Previous Value Of A Field In A Table

Apr 22, 2014

I have a simple Table with the following structure:

ID
Product
Current_Level
Received
Available

How can I retrieve the previous value of the field [Available] and to set this value for the new [Current_Level] ???

View 7 Replies View Related

Accessing Field From Previous Form

Dec 6, 2012

I'm working with a form (MainF) ... which has a subform (MainSubF). The subform has buttons that link you to other forms. When you click on one of those buttons, I have a control number that links the two forms by putting a CTR field into the linked form with a ctr defaul that = forms!mainf!ctr.

My problem is that I'd like to use this subform on other forms. However, if I put the subform onto another form such as "MainTwo", none of the buttons on the subform will work because the path is now wrong. Is there a generic way to connect the buttons to whatever form the subform is attached to??

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved