Calculate A New Value Conditionally Based On 2 Records

May 1, 2006

I am trying to write an expression that calculates a new field in a query. The new field is simply recoding values from another field (survey question responses) using IIf statements. This new field, let's call it RecodedResponse, will eventually be summed in a totals query to get the total score on that survey for each participant. Each record is a question response and there are multiple records for each participant (16 items on this particular survey). The problem is that for 2 of the questions on this 16 item survey, the responses are supposed to be eventually combined and recoded based on each other. So, my question is:

Is there a way to do a conditional expression where the result from the previous record is used? Or do I need to first do a crosstab query so that all the responses for one participant are on one line?

I am pretty sure I can do a workaround to make it work, probably doing a crosstab, then recoding in another query based on the crosstab, but it would be cleaner (I think) to do this some other way. Any ideas? Or is this too vague?

Thanks,
Liz

View Replies


ADVERTISEMENT

Forms :: Conditionally Change Back Color Based On Value Of A Control

Mar 15, 2014

How do I conditionally change the Back Color and Alternate Back Color based on the value of notes.FollowUpDate? I have a continuous form using the following code:

Code:
Private Sub b_all_past_Click()
Me.resultsFrame.SourceObject = "FollowUp_bystaff"
Me.resultsFrame.Form.RecordSource = "SELECT * From notes WHERE (((Notes.FollowUpDate) < Date()+1) And ((Notes.followup_person_id) = GetCurrentUserId()))ORDER BY notes.priority,(notes.FollowUpDate) DESC;" '
End Sub

View 1 Replies View Related

Calculate A Date Based On Dropdown

Feb 1, 2006

I have a drop down box in my access database which I want to use to give completion dates to jobs, the drop down has three values:

Emergency
Urgent
Routine

emergency equates to 1 day
Urgent 7days
Routine 28days

I have had a dig in the help files and I can get the order completion date to show the terms emrgency, urgent and routine, however I nned to calculate the date, not just show the term, this where I lose track of how to get any further, I have searched the forum and cannot find an example, but perhaps I am not using the right search criteria, I have tried date calculation on drop down results etc etc and no dice, I am sorry if I am posting a question whichg has already been answered, and if anyone can post a link to a solution that would be great to.

Many thanks for your help this is my first post on this forum, but I am sure I will be here for a long tme to come access is fast becoming my life :D

again many thanks for taking the time to read this and I appreciate any help you can give me.

View 3 Replies View Related

Calculate A Date Based On Dropdown

Feb 1, 2006

I have a drop down box in my access database which I want to use to give completion dates to jobs, the drop down has three values:

Emergency
Urgent
Routine

emergency equates to 1 day
Urgent 7days
Routine 28days

I have had a dig in the help files and I can get the order completion date to show the terms emrgency, urgent and routine, however I need to calculate the date, not just show the term, this where I lose track of how to get any further, I have searched the forum and cannot find an example, but perhaps I am not using the right search criteria, I have tried date calculation on drop down results etc etc and no dice, I am sorry if I am posting a question whichg has already been answered, and if anyone can post a link to a solution that would be great to.

Many thanks for your help this is my first post on this forum, but I am sure I will be here for a long tme to come access is fast becoming my life :D

again many thanks for taking the time to read this and I appreciate any help you can give me.

View 6 Replies View Related

Calculate An Age Based On Date Of Birth

Oct 18, 2004

This is my first post to this group. I am building a database for a charity event and need to calculate the age of a person based on the Date Of Birth field in the table and add that number to a separate column in the table. Also, need to calculate the age as of a certain date (the beginning of the event). Thank you for any help.

Larry

View 3 Replies View Related

Calculate Age Based On Date Of Birth

May 22, 2014

I am using Access 2007, and am new to Access.

I would like to calculate the Age based on the Date of Birth , which is in dd/mm/yyyy

I use the below expression in Query but I get back #Error for most records; whereas the Age appears correctly for a few records.

Age: DateDiff ("yyyy", [BirthDate], Date())

View 14 Replies View Related

Calculate Days Open Based On Status

Mar 21, 2006

I am not sure if what I am about to ask is best done in a query, table or report, so I thought I would post this in the query section of the forum.

I have a table that contains the following fields (plus other fields)

RC_START_DATE
RC_DUE_DATE
RC_APPROVAL_DATE
RC_STATUS

On one of my reports, I want to show the "Days Open". If the RC_Status is "Active" I want to calculate the "Days Open" by subtracting RC_START_DATE from Today(). However if the RC_Status is "Closed" I want the "Days Open" to be calculated by RC_APPROVAL_DATE minus RC_START_DATE.

So the question is, what is the best way to do this and how would I write the formula to calculate this?

Thanks for the help.

Jim

View 6 Replies View Related

Calculate Future Dates Based On Inputs

Jun 14, 2007

Hello,

Was wondering if it is possible to create a query or another method that would calculate future dates based on inputted info ?

For example a person inputs on a form a date completed (06/14/07) and then also selects a frequency of when this has to be revisited....monthly, quarterly, semi-annually.

So based on the date completed that the person inputs I'm trying to get the date if they select monthly of 7/14/07 (using above date example).

Any help would be greatly appreciated.

Thank you

View 3 Replies View Related

Calculate Due Date Based On Fields From Another Table

Sep 22, 2011

I have a form for entering safety training which includes Training Date and Expiration Date, this form is called "Scheduled Training".

The table containing training courses with their requirements and frequency is called "Course Requirements". Within this table I have a "Frequency" field (1, 2, 3, 4, 5, 6) and another field "FrequencyPeriod" (Year, Month, Initial, As Needed).

What I'd like for the Expiration Date on the form to do: Use [ScheduledTraining].[Training Date] and look at both the [CourseRequirements].[Frequency] & [CourseRequirements].[FrequencyPeriod] to populate the Expiration Date.

View 14 Replies View Related

Field In A Database That Calculate Age Of A Person Based On DOB?

Jun 23, 2014

I need to have a field in a database that will calculate the age of a person, based on their DOB. I have it in the excel sheet that I imported into Access to create the data base, but it just copied the number that was already there. When I add new entries into the database, the age isn't calculated. How do I do this?

The forumla I use in my spreadsheet is: =DATEDIF(O2,TODAY(),"y")

View 1 Replies View Related

General :: Query To Calculate Points Based On Dates

Jul 1, 2015

I am trying to create an attendance database, our company introducing the point system attendance,

Called Off (CO) 2 points
Left Early (LE) 1 Point
Tardy (Tar) 1 point

Employee can reduce point if they have perfect attendance for 90 days from the last day of violation. For example, an employee absent on 01/01/2015, he will received 2 points, the credit will giving on 04/01/2015, if there is no violation, but if he absent again on 03/31/2015 not only he will received 2 more points his 90 days will start from 03/31/2015, now he will eligible to get credit on 06/29/2015 and so on.So far I have created 3 tables and 1 query.

Tables

Employees: Id, Last Name, First Name
Points: Id, Description Points
Attendance:Id, Date, Employee ID, Points ID

Query
Date
Employee ID
Last Name
First Name
Point Description
Points

how and which formula to use which calculate the points based on above example.

View 14 Replies View Related

Modules & VBA :: Calculate Next Service Month Based On Dates

Jan 16, 2015

I've been trying to solve this problem for the past month and at the verge of destroying my PC! I've trawled through numerous web sites but just cant seem to figure this one out.I'm trying to get access to tell me what the next service moth is based on the start date, end date, and the frequency of service.

For example:

Start date: 01/01/2014
End date: 31/12/2015

service frequency: Every 4 months

Using the above information the service months are:
1 - April 2014
2 - August 2014
3 - December 2014
4 - April 2015
5 - August 2015
6 - December 2015

View 6 Replies View Related

Forms :: Calculate Field Based On Second Column Of Selection

Nov 20, 2014

I have a form, where one field is a combo box

The combo box is two columns linked to at table,

task and sla

You pick the task, and it displays the task

What i need is, another field, to equal the SLA part of that task.

View 5 Replies View Related

Modules & VBA :: Calculate Time Periods Based On A Given Tariff

Mar 25, 2014

Suppose that you want to make a formula which will calculate time periods based on a given tariff. To be more precise.

Suppose you can "get in" somewhere, entrance is $2.
You are free to stay there, without additional charge, for 5 days.
Then, for the next 5 days, the charge is $1 per day
The next 7 days, the charge is $1.5 per day
Thereafter, $3 per day.

In this scenario, we can make a query, we use datediff function to see the number of days between "gate in" and "gate out".

The problem is that the tariff is not very simple and the query gets to big and difficult to control with lot's of "iif" and may be I need to make more than 4 queries and union select and so on.

I tried to find in the docmd if there is any suitable function that I could use.

View 7 Replies View Related

Reports :: Calculate Percentages Based On Criteria In Report?

Oct 22, 2013

I created a database to record time logged per workorder for each employee on my job. Each time log has a specific "Trade" attached to it along with a number of hours the employee spent on that workorder. I've created a report to display how much time the selected employee spent on each workorder (within a date range) and now I want to see what percentage of their time was spent on a particular "Trade" (for instance, during September Employee "name" spent "percentage" of their time on Electric, "percentage" on HVAC, "percentage" on Plumbing...[and so on])

I have trades listed in the table and in the time log, the form writes to the trades area of the table (probably very elementary for this discussion) and the report lists the name and grand totals with percentage of total time on each workorder, but does not list any trade information.

How can I add this into my report, preferably at the end (Report Footer?)

View 4 Replies View Related

Queries :: Calculate Totals Column Based On Check Box Selections

Mar 15, 2013

I'm trying to create a query to work out the total amount to invoice based upon some selections. Currently my query looks at the values in several fields (numberOfRollsUsed etc) by taking the value in these fields and multiplying by a fixed amount to calculate the total.

What I would like to add to the query is fixed values based upon some check box selections. So if check box A is selected, add 5 to the total, is check box B is selected, add a further 10, and so on. All fields and check boxes are held within the same table (Job).

Am I being daft or trying to do something in the worst way possible? I'm actually adding this to an existing system so I don't have so many options to completely redesign the system to calculate this in a better way.

View 2 Replies View Related

Queries :: Calculate Ratio And Then Arrange Result Based On Facility Types

Mar 20, 2013

I have a simple query like below.

Code:
SELECT [score_admit] / SELECT [score_discharge] AS Ratio, facility_type
FROM tbl_test
group by facility_type;

It's really just based on one table, but what I'm trying to do is to calculate the ratio for the scores, then arrange the result based on facility types.

The error I get is a syntax error the SELECT statements.

View 3 Replies View Related

Queries :: Calculate New Fields Based On Current And Prior Year-end Numbers

May 6, 2013

I am creating a Make Table Query and calculating new fields based on current and prior year-end numbers. If the prior year-end number does not exist (Is Null), I want the use the current rate or calculate the change in rate. I have typed the below in the Field Box:

CHG_IN_PGM_RATE: IIf(([P0_10 Tbl - AM PYE PTD Detail w Rates]![PTD_PYE_PGM_RATE]) Is Null,([MASTER LIST CURRENT]![PTD_PM_PGM_RATE]),(([MASTER LIST CURRENT]![PTD_PM_PGM_RATE])-([P0_10 Tbl - AM PYE PTD Detail w Rates]![PTD_PYE_PGM_RATE])))

However, when running the query, I get the attached error message.

The screenshot will also show how the two tables are joined.

View 2 Replies View Related

IIF Statement - Calculate Value Based On Comparing Current Date To Dates In Fields

Jun 27, 2013

In my table I have the following 4 fields with the associated date field:

Bronze: 11/1/2013
Silver: 5/1/2014
Gold: 11/1/2014
Platinum: 5/1/2015

I am trying to calculate a value based on comparing the current date to the dates in these fields. I am using the below formula. However, using 6/27/2013 as the current date, my formula keeps resulting in "Bronze" when it should result in "Standard" Am I doing something wrong?

=IIf(Date()<[Bronze],"Standard",IIf((Date()>=[Bronze]) And (Date()<[Silver]),"Bronze",IIf(Date()>=[Silver] And Date()<[Gold],"Silver",IIf(Date()>=[Gold] And Date()<[Platinum],"Gold","Platinum"))))

View 5 Replies View Related

Forms :: Calculate Difference Between Records

Jul 25, 2014

I have looked all over for a way to calculate the difference between water meeter readings. My brain may be Friday slow, but all I can find is for calculating differences in dates. My water table has 3 fields: ReadDate, Reading, Calc1

ReadDate is the date the water reading occurred
Reading is the meter reading
Calc1 is calculated (when I find out how!) by subtracting the current reading from the previous day's reading.

I would like to add the write script in my form so when the readings are entered, the calculation auto populates the field for the user.

View 6 Replies View Related

Need An Elegant Way To Calculate Difference Between Numerical Records.

Nov 1, 2007

I'm new to building databases and I wouldn't think that this is difficult but it has stumped me and everyone that I have approached to elegantly perform this calculation.

Essentially I have a table of meters (the best real world example is the watermeter that your community uses to measure how much water you use each month.) Each meter in the table has a "child table" of the date/time that the meter was read and the reading on the meter (stored as a number). I need to calculate the difference between the last two readings in the child table for each meter(essentially how much water each meter has used since the last reading.)

I have been able to sum, average, etc. the meter readings, but I can't seem to find a way to get a difference.

Thanks in advance,

Corwin

View 12 Replies View Related

Queries :: Extract Or Calculate Number Of Records In A Sequence

Jan 4, 2014

How to extract or calculate the number of records in a sequence - e.g. in a table/query ordered by ID and date, the number of consecutive records by date for a given ID that have a value >= 50 in a given field. Is there a way of doing this purely within a query, or would I have to resort to a VBA loop through a recordset and keep a count of the consecutive records that match that criteria?

View 3 Replies View Related

Conditionally Numbered Sequence

Aug 29, 2006

Hi,

I have a table with 400,000 (approx) records in the following format:

a(PK:AutoNum) - b(text)-c(text)-d(Num)-e(text) - f (text - unique/random)
A B C D E F
1 - 6767 - P2 - 1 - 24/992 - 34341212
2 - 6767 - P2 - 1 - 24/993 - 87657483
3 - 6767 - P2 - 1 - 24/995 - 98764536
4 - 6767 - P2 - 2 - 24/996 - 87543297
5 - 6767 - P2 - 2 - 24/998 - 98674635
6 - 6767 - P2 - 2 - 24/999 - 34546576
7 - 6767 - P2 - 2 - 25/001 - 98768547
8 - 6767 - P2 - 2 - 25/002 - 46576897
9 - 6767 - P2 - 2 - 25/004 - 62536475

I need to create a new field in a query that acts like an autonumber, that resets based on an increase in field (d).

ie:

1 - 6767 - P2 - 1 - 24/992 - 34341212 - 1
2 - 6767 - P2 - 1 - 24/993 - 87657483 - 2
3 - 6767 - P2 - 1 - 24/995 - 98764536 - 3
4 - 6767 - P2 - 2 - 24/996 - 87543297 - 1
5 - 6767 - P2 - 2 - 24/998 - 98674635 - 2
6 - 6767 - P2 - 2 - 24/999 - 34546576 - 3
7 - 6767 - P2 - 2 - 25/001 - 98768547 - 4
8 - 6767 - P2 - 2 - 25/002 - 46576897 - 5
9 - 6767 - P2 - 2 - 25/004 - 62536475 - 6

I initially thought I could make an IIF expression that basically says: if [d] in this row is the same as [d] in the previous row then add 1 to the previous record [new number], otherwise, enter 1 in this record [new number] (thereby resetting it)....

I have searched the forums for 'numbered sequences' (amongst other things), and it appears that either the Dcount or Dmax function appear to be the solution, but I'm having some trouble applying it to this problem. I was hoping someone can help me through it.

Cheers

View 1 Replies View Related

Conditionally Setting The Value Of An Expression

Aug 30, 2006

I am trying to enter an experssion into the grid for age groups. The result will be a text value based on the value in a column named Age. There are three groups, '<18', '18-30', and '31+'. I tried using the following but the result that is returned is #Error.

age_grp: Switch([age]<18,'<18',[age]>=18 And [age]<31,'18 -30',[age]>30,'31+')

Do I have the syntax wrong? or maybe I'm going about it completely wrong.

I have also tried a nested iif statement Age2:= iif([age]<18,'<18', iif([age] >=18 And < 31, '18-30'), iif([age] >30, '31+')). I get the same error message.

This worked for displaying the value on a report =IIf([age]>=18 And [age]<=30,"18-30",'31+'). However, I need to sort and group by the value so I can count the number in each group, so I wanted to put it into a query.

Thanks,
Christy

View 4 Replies View Related

Conditionally Lock Record

Apr 11, 2005

OS/Program :xp/Access 2002

The following problem. Within my main form I have a status field. Dependent of the status of the main field I would like to lock the total record in my sub form at once. Within which event of the sub form could I achieve this and which property locks a total record?

thanks
giovi

View 2 Replies View Related

Conditionally Suppress On A Form

Oct 10, 2005

Hi all

Long time searcher, first time poster!

I have a subform which has loads of check boxes for each record but i want to suppress certain boxes depending on criteria in each record. I think i need to do a For..Each statement but, as my user name suggests, I'm buggered!.

View 2 Replies View Related







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