Queries :: Lookup And Calculations Between 2 Queries?

Jun 20, 2014

I have 2 queries 1 called [Prod Performance]

the second query is called [Shifts]

Field within [Prod Perf] which I want to use is called [Prod Date] & [Hrs]

Field within [Shifts] which I want to use is called [Shift Date] & [Shift Total]

I need a query to compare dates which match from both queries and then divide [Shift total] / [Hrs] to give a number.

View Replies


ADVERTISEMENT

Queries :: Adding Calculations To Queries Based On Columns In Query

Feb 18, 2014

I am trying to add calculations to queries based on columns in the query... it seems to randomly expect 'Expression' or 'Group by' as column types, and Im having to create 3 sets of queries following on from each other to de-dupe data and allow filters on calculated values.

Also I've got a function which turns a date into a quarterly cohort, e.g. Oct 2013 -> 20134. I use ot on a lot of dates. I created a VBA function, CohortQ used as follows in queries:

Cohort: IIf Year([InputDate]) < 1990 or Year([InputDate]) > 2020, 0 CohortQ([InputDate]))

In the VBA, InputDate is defined as a date

Code:
Function CohortQ(InputDate As Date) As Integer
If InputDate = 0 Then
CohortQ = 0
Exit Function
End If

[Code] .....

But when I run it on a date field, it gives me a data mismatch error. I can't step through as it's working on 600K rows.
If I put the function into the query,

Cohort: IIf Year([InputDate]) < 1990 or Year([InputDate]) > 2020, 0 Year([InputDate])*10+DatePart("q",[InputDate]))

it works.

View 3 Replies View Related

Queries :: Implementing YTD Calculations In Access?

Jul 22, 2014

How to implement YTD calculations in Access.

Current table:

Property Month RevenueA Jan '13 100
A Feb '13 50
B Jan '14 200
B Feb '14 300

Desired output:

Property Month Revenue YTD revenue
A Jan '13 100 100
A Feb '13 50 150
B Jan '14 200 200
B Feb '14 300 500

I am new to Access programing and have not been able to figure out a query/macro to execute this.

View 3 Replies View Related

Queries :: Run To Extract Some Values For Calculations

May 12, 2015

I have a query that I run to extract some values for calculations. Its run on an event based on a dropdown selection. At the moment, I run via:

Code:
DoCmd.OpenQuery "CallMidprice"

and then close it. this seems to take more time than is necessary when I only want to refresh the results.Open query without close, switches to the table but doesn't update until I press F5.When I try requery I get an error. "Runtime error '2109': There is no field named 'CallMidprice' in the current record.

Requery without 'Callprice' seems to requery my form.

View 5 Replies View Related

Queries :: Calculations On Query Results

May 20, 2013

I need to do a calculation on the RESULTS of a query. Each record in the table I'm querying has a date stamp. I have a query that produces a list of the newest records for each machine. I want to calculate how old each of those records is based on today's date.

So far when I try to include the calculation in that query, it returns all the records instead of the newest ones. This makes me think I'm doing something fundamentally incorrect. The calculation is affecting the query results where I just want to do the calculation on the results. What I'm trying to ultimately do is have a way for the users to see a list of machines that are overdue for a certain procedure. I was thinking of putting a button on a form that will run the query and present the list, perhaps with some conditional formatting highlighting the machines that are overdue, etc. Do I need to just use 2 queries?

View 14 Replies View Related

Queries :: Calculations With Values In Previous Record(s)

Jan 12, 2015

I have a database where I need to record student data, specifically marks and absenteeism. The marks are recorded each term as a running total. I have a final mark which needs to be equal to the 4th term mark.

I also need to record the number of days absent each term with a total at the end of the year.

My problem is that the term 4 mark is a in the previous record and the total days absent needs to be the total of the previous 4 records (term 1 - 4).

I using a create table query and an update query but that was a no go.

View 7 Replies View Related

General :: How To Use VBA In Case Of Complex Calculations Instead Of Queries

May 29, 2014

i just know some query designing and some amount of VBA for making small event procedures.I want to know how we can use VBA when our queries becomes complex to replace the queries and to extend the functionality.how to use recordsets in a VBA function.

View 5 Replies View Related

Queries :: Getting Required Data Using Query For Calculations To Be Used Later?

Nov 7, 2014

I've been trying unsuccessfully for weeks to try and query a usable data set that would later be used for calculated values in a report.

I'm building a Hospital Acquired Infections Database for my facility to record data and process reports automatically. Previously, I built the system in Excel using VBA and userforms, but the size of the file has become too cumbersome, and now takes too long to process my reports.

So here's the issue.

UNIT_DATA TABLE:
UNIT
INF_MONTH
INF_YEAR
PT_DAYS
CVC_DAYS
IUC_DAYS
VENT_DAYS
APV_DAYS

PT_LEVEL TABLE (There are many fields in this table for recording purposes but I will only list the ones I need for reporting purposes):

UNIT
INF_STE_MAJ
SPECIF_SITE
INF_MONTH
INF_YEAR

So the important numbers I can't seem to collect are the total number infections per month from the PT_LEVEL Table for only select SPECIF_SITE infections.

the Tables are joined Left to Right as Follows:

UNIT_DATA.UNIT - PT_LEVEL.UNIT
UNIT_DATA.INF_MONTH - PT_LEVEL.INF_MONTH
UNIT_DATA.INF_YEAR - PT_LEVEL.INF_YEAR

The UNIT_DATA Table is a monthly collection for the 5 metrics (PT_DAYS, CVC_DAYS, IUC_DAYS, VENT_DAYS, APV_DAYS) regardless of whether or not the number for each is zero. Every unit in the database will have a record for each month and year.

The PT_LEVEL Table will only have records if and when a patient develops an infection. This means there is no cumulative monthly data for the PT_LEVEL Table Data based on SPECIF_SITE infection type.

I need to first do a roll up count for every month and year in the database, for which I was initially trying to use the UNIT_DATA table for since it contains every month and year. The problem is when I try to query the SPECIF_SITE from PT_LEVEL, I can get the number of Infections for months where infections where present for each unit and null values, for each month, and each year in UNIT_DATA, but when I include a where condition to narrow the view to only selected SPECIF_SITE's it only shows data for that SPECIF_SITE for months where they occured.

I need a cummulative monthly aggregation of the totals for a selection of SPECIF_SITE infections, for every unit, for every month, and every year, since July 2010.

View 14 Replies View Related

Queries :: Applying Calculations To Date Ranges

Aug 10, 2015

I need a query that will relate values to given date ranges. For Example:

Table: TaxTypeRange
Values:
TaxType; FromDate; ToDate; Contact
W2; 1/1/15; 3/31/15; Tom
1099; 4/1/15; 6/30/15; Tom
W2; 7/1/15; 12/31/15; Tom

Table: Bills
Values:
Contact; BillAmount; BillDate
Tom; 1000; 3/31/15
Tom; 1100; 4/30/15
Tom; 1200; 5/31/15
Tom; 1300; 6/30/15
Tom; 1400; 7/31/15

Requirement: For every period where the TaxType = W2 the query should multiply the Bill amount by 1.20, so the result should be something like this:

Query: BillsAndTax
Values:
Contact; BillAmount; BillDate; TotalBill
Tom; 1000; 3/31/15; 1200 (TaxType = W2 so 1000* 1.2)
Tom; 1100; 4/30/15; 1100 (TaxType = 1099 does not apply 1.20)
Tom; 1200; 5/31/15; 1200 (TaxType = 1099 does not apply 1.20)
Tom; 1300; 6/30/15; 1300 (TaxType = 1099 does not apply 1.20)
Tom; 1400; 7/31/15; 1680 (TaxType = W2 so 1400 * 1.2)

Not sure how to set this up the right way.

View 3 Replies View Related

Queries :: If Function - Calculations Based On Field

Dec 15, 2014

I would like queries to do some calculations for me based on a field. The field in the form is a combo field and the user can choose either 1, 2 or 3. Based on the selection, I would like queries to generate some numbers for me.

This is what I have in mind but its not working.

Code : TEST RESULT: If([tlkpTEST].[RESULTID])=1, ([tlkpTEST].[RESULTID])*2, 100)

View 2 Replies View Related

Lookup Choices Controlling Calculations

Dec 18, 2014

I am running Access 2010 on a Windows 7 platform and attempting to write a simple database for a local charity, and whilst I have basic skills in Access I would not put my level higher that enthusiastic amateur.I have a couple of fields, one called 'Income' which is a simple currency field. The second field is called Frequency and is a combo field where the user can choose from Weekly; Monthly; Quarterly; or Annual.

The database user enters data taken from a survey sheet which captures the income of an individual along with the frequency of the payment.The requirement.I would like to create a calculated field which gives the annual income.

Example:
Income = $5,000 Frequency = Monthly
the calculated field would return (5,000 x 12) = 60,000

Equally
Income = $1,000 Frequency = Weekly would return (1,000 x 52) = 52,000

View 2 Replies View Related

Queries :: Keeping Records Of GST Transactions - How To Do Calculations In Query

Apr 5, 2013

I am trying to keep records of GST transactions.

I have a problem in figuring out how to do calculations in a query.

How to have the calculation in the attached MDB and Document for field #105_SubTotal and the field #115_PaymentEnclosed.

View 7 Replies View Related

Queries :: Timesheet Calculations - Round Up To Nearest Fifteen Minutes

Sep 2, 2013

I have a timesheet database, which has the exact start time and exact end time. I want to ignore this if it is five minutes either side of the half hour, and display the exact half hour, but otherwise want to round it UP to the nearest fifteen minutes.

For example:

Exact Start: 09:58:23 Displays as: 10:00:00
Exact Start: 09:42:16 Displays as: 09:45:00
Exact Start: 09:02:08 Displays as: 09:00:00
Exact Start: 09:07:01 Displays as: 09:15:00
Exact Start: 09:23:03 Displays as: 09:30:00
Exact Start: 09:33:00 Displays as: 09:30:00
Exact Start: 09:36:04 Displays as: 09:45:00

View 11 Replies View Related

Lookup Tables And Queries

Aug 22, 2006

I have a database that has been developed by a consultant. Unfortunately the database contains look-up tables. Obviously when I query it returns and references the codes for the lookup field rather than the lookup field value. Unfortunately I am unable to change the database to remove lookup fields/tables. How can I get around this to produce tables with the lookup field value or perhaps reproduce the old tables (without just cut and paste) to then conduct my queries. Am I missing something simple as I am fairly new to Access development.

Regards,
Deesy.

View 2 Replies View Related

Queries :: Form Field Lookup

Jun 18, 2013

I have a form with a combo box that contains a list of Employee Names which are contained in an Employee table (column 1).Just below it I have a textbox titled Employee Number. This field should remain blank until an Employee name is chosen from the combo box at which time it should populate with the corresponding Employee number which is column 2 of the Employee table.

View 5 Replies View Related

Queries :: Filtered Lookup In Combo Box?

Jan 28, 2014

Where MS Excel is concerned there is very little I can't do and I am now transferring that skill to MS Access and I'm stumbling on this one.

In Excel I would use the INDIRECT formula within the validation and named range to do this but in Access I'm struggling to get this to work.

I have in table TBL_NL_Structure a list of CLIENT_ID with NL_ACCOUNTS against them i.e.

CLIENT_ID....ACCOUNTS
900001.........4000
900001.........4001
900002.........4003

What I want to be able to do is in a sub form and a combo box named ACCOUNT that looks at the active CLIENT_ID and pulls into to combo box JUST the ACCOUNTS set to that CLIENT_ID example if the CLIENT_ID is 900001 is just brings in ACCOUNTS 4000 & 4001.

I can get the whole list to come in to the combo box but not a filtered list.

View 3 Replies View Related

Queries :: Lookup Using Part Of A Field

Feb 28, 2015

I have a table - RDC/NDC - that holds details about various warehouses, including a field - [Short_Code] (TEXT) - to hold the warehouse short code or ID.

I have an import table - PickDataImport - that contains details of goods picked, including a field - ToAssignRef (TEXT) - that is made up of 3 elements; Type-Short_Code-Date (EG GREEN-MAN-210215).

I am trying to create a query that will return the warehouse name from RDC/NDC by looking up the depot short code in the ToAssignRef.

The Type element of ToAssignRef can be any length of text.

I am thinking i need to use HAVING or IN (or a combination) but everything i try fails - either blank or errors.

View 10 Replies View Related

Queries :: Lookup Previous Value For Employee

Aug 9, 2015

I currently have a table where we are logging a task number against a date and time for each employees to track activity.What I am looking to do is in a query have access lookup the previous reference number for the employee before the date/time of the individual record but on the same day

example
Staff 1 08/08/2015 12:00 Task Ref: 1234
Staff 1 09/08/2015 14:00 Task Ref: 3456
Staff 1 09/08/2015 15:00 Task Ref: 7891

to show something like
Staff 1 08/08/2015 12:00 Ref:1234 Previous Ref: Null
Staff 1 09/08/2015 14:00 Ref: 3456 Previous Ref: Null
Staff 1 09/08/2015 15:00 Ref: 7891 Previous Ref: 3456

Fields are
Employee
DTActStart - this is when task started
DTActEnd - this is when activity ended
Task ID - Reference for task (unique field)

I've tried seaching forums (Used DMax and Lookup) but doesnt find the most recent record before the in view record/I'm thinking a query is the best way so that when Print a report of tasks run of tasks will then show

View 3 Replies View Related

Queries :: Lookup Column Query

Jun 16, 2013

What I am wanting to do is to have columns at the end of my imported data that reference another table to tell me based on the queue what service type and centre it relates to.

I have attached 2 pictures one with table 1 and the other with table 2. Table one shows the last column 'SERVICE_TYPE' which I need to lookup from the reference table (aka table 2 - which has been attached).

View 3 Replies View Related

Queries :: Lookup Using Multiple Fields

Jun 5, 2013

I have a query that based on certain codes in a record does multiple joins to pull in other codes... I want the query (based on these pulled in codes) to do a lookup in another table to extract 1 field that has a description...

Can I do this in one query??? Do I need to do a Make Table to first pull in the codes and then do a second query with a DLookup based on those fields???

View 3 Replies View Related

Challenge: Real Time Queries And Lookup

Mar 4, 2006

Greetings!

Hoping somone could help me here.

I am trying to create a database (duh!). At the moment, I have two tables. One table is a small timetable with the fields:

Day, Airline, Flight Number, Time, Origin, Destination, Aircraft

The other table (Delay) has the following fields:

Date, Day, Airline, Flight Number, Time, Origin, Destination, Delayed by.

I would like to do the following. In Delay I put in the date: 01/07/2005, fine. The Day (field format Date/Time dddd) is also 01/07/2005 which Access transofrms into the word "Friday". Airilne is BA. In Flight Numbers, I want the database to do a query on "TIMETABLE" to search all flights that operate on a Friday as some do not operate daily. (By the way in the 'Day' column of Timetable the values are "Monday Tuesday Wednesday Thursday Friday Saturday Sunday" or "Monday Thursday Saturday" depending on the flight). This query/lookup should be performed right after I type 01/07/2005 in the "day" field of "Table: Delay". A lookup combo box should be displayed when I arrive at the field FLight Number. I select a flight (e.g.: BA001) and automatically the Time, Origin and Destination of the flight should appear in the "Table: Delay".

I have been unsuccessful at even getting past the first hurdle. I tried a query of the "Table: Timetable" and fields "Day" and "Flight Number". The Criteria I do not know what to put in. "Like [Delay]![Day]" or "[Delay]![Day]" does not help and brings up nothing. However, "Like *Monday*" does bring up all the flights which operate on a Monday. However isn't there some way of telling the query to automatically occur after I type in the relevant day in the "Delay" table? Futhermore I would like to avoid (but not totally exclude if it's impossible) macros as eventually I hope to publish this to SQL or whatever.

Cheers in advance.

View 1 Replies View Related

Modules & VBA :: Lookup Function To Use In Multiple Queries

Jul 24, 2015

I have a database with various tables containing information about students, timetabling, assignment submission dates and multiple tables with grades for various assessments. All grades are held as percentages.

In a large number of different queries / reports I want to output the grade as an item from verbose scale with 17 points (excellent first, high first etc.). I've set up a table called 17pointscale which contains fields called 17pointscale (with the verbose names), lowerlimit (number) and upperlimit (number).

I have a query in SQL (which works) to take the percentage grade from one of my grade tables AssessedWorkGrades.Grade and return the text on the 17 point scale.

SELECT AssessedWorkGrades.Grade, [17PointScale].[17PointScale]
FROM AssessedWorkGrades LEFT JOIN 17PointScale ON ([AssessedWorkGrades].[Grade]
>= [17PointScale].[LowerLimit]) AND ([AssessedWorkGrades].[Grade] <= [17PointScale].[UpperLimit]);

Is there any way of converting the SQL to a custom vba function which would enable me to use this as a lookup in a large number of queries.

I think that it should be possible to set up a function called ScaleGrade and in any query Expression: ScaleGrade(XXX) will take XXX and return the 17 point scale.

I think that AssessedWorkGrades.Grade needs to be replaced by a variable that is inputted on use of the function but am not sure how to accomplish this.

View 1 Replies View Related

Queries :: Lookup At The Previous Record In The Table

Jan 25, 2014

I've got stuck in preparation of this sales query. The primary sales table contains a mix of Canadian and the US detail invoice sales records. All sales records are in their native currencies The secondary lookup table contains daily US/CAN foreign exchange rates (FX).

I need to multiply every $US sales record (marked with U) with the FX rate in order to convert it to the Canadian currency. Unfortunately, this FX lookup table is missing over 50 daily rates in the last two years and as a result I cannot match them date-by-date with the sales table.

As a workaround, it is acceptable to use the previous FX rate in the table. The previous rate can be one or more days before the transaction occurred.

Attached is a sample database with the query that I've already built. The query contains two sample US records that are missing the FX rate on Jan 6. The FX rate of $1.0639 that needs to be applied to it should come from Jan 3rd entry.

New Datesales matcode curtype trans newrate
1/3/20141225.61281173224U R187611.0639
1/3/2014344.70361173260U R181731.0639
1/6/20142520 0022691U R19841
1/6/20145400 0022692U R19841

View 14 Replies View Related

Queries :: Lookup Multiple Values And Use Both Separately

Jun 24, 2014

I have two tables one with all the personnel (tblPersonnel) I'm tracking, another with different report names (tblReports).

For each report, there are different years that it's valid for.

On the reports table, I have three columns, ReportID, Report_Title, and Years_Valid

I'm using a lookup on the personnel table that stores the report name as the ReportID.

What I want to do is in a query use the Years_Valid column to automatically generate review dates bases on dates already in the database.

View 6 Replies View Related

Queries :: How To Lookup Date And Return Value From Another Table

Jul 30, 2015

Basically, i have a table ("Transaction") with payment date and another table ("Control") with accounting dates and corresponding year/month.

Objective: I need to know which accounting year or month these payment date fall under.

Example: If the payment date is 18 Dec 2013, the accounting year should read as 2013 and the accounting month should read as 12.

In excel, this is very simple using vlookup.

I tried for hours using access dlookup query and i'm still stucked ..

View 4 Replies View Related

Queries :: Create Query To Do A Lookup From Another Database

May 28, 2014

I am trying to do a lookup from a field from one of my databases (DB1) onto another field in (DB2).... I have been using excel to do vlookups but a report that I do weekly I do atleast 7 lookups for the past weeks... So I am trying to find a way in access to do lookups and save those lookups each time i run the report... Do I have to create the query and make the ID the primary key on both the databases and then create a relationship?

View 7 Replies View Related







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