Queries :: Calculate Multiple Values Same Field

Feb 22, 2014

I have a table where there are multiple vehicles, each identified by their vehiclenumber. Each record holds the vehiclenumber, date and odometer reading. I need to figure out how to calculate records in this table per each vehiclenumber.

Below is a code that works, but only when i have each vehicle with the same vehiclenumber.

SELECT tblOdometer.VehicleNum, tblOdometer.ODate, tblOdometer.Odometer, tblOdometer.Odometer AS OdomAlias,
Nz(DLast("Odometer","tblOdometer","[Odometer] < " & [OdomAlias]),0) AS Previous, [Odometer]-[Previous] AS Difference
FROM tblOdometer;

View Replies


ADVERTISEMENT

Queries :: Calculate Cumulative Values Stored In Field

Oct 7, 2013

I have several projects with different tasks for each. I have 3 fields [fkProjectsID], [TaskOrder] and [Duration] in a table for project tracking with that structure:

[fkProjectsID] [TaskOrder] [Duration]
1 /1 /5
1 /2 /8
1 /3 /15
1 /4 /6
2 /1 /8
2 /2 /30
2 /3 /25

I want to calculate cumulative values stored in [Duration] field (represent a number of days). I'm using the field [TaskOrder] to order different tasks within each project. With some testing, I was able to calculate cumulative [Duration] with 1 project using the DSum fucntion as following:

CumulDuration: DSum("[Duration]", "[tblProjectTracking]", "[TaskOrder]<=" & [TaskOrder])

I was having the sequence: 5, 13, 28, 34 for respectively Task 1,2,3,4. However, when I add a second project (and then a third...), I need to be able to filter based on [fkProjectsID] as well (i.e. a specific DSum by ProjectsID). I add this criteria but I get the sum of [Duration] on each row instead of the cumulative:

CumulDuration: DSum("[Duration]","[tblProjectTracking]","[TaskOrder]<=" & [TaskOrder] And "[fkProjectsID]=" & [fkProjectsID])

View 3 Replies View Related

Queries :: Query With Field Containing Multiple Values?

Jun 21, 2014

modify the code below to Show the LocationName in the Schema Column instead of the MPID? I attached a pic showing the relationship between the two tables which contain the data I'm trying to query.

SELECT [Locations Query].LocID, Qry_MPLoc.MPID AS Qry_MPLoc_MPID, [Locations Query].Location, [Locations Query].Schema
FROM [Locations Query] INNER JOIN Qry_MPLoc ON [Locations Query].[LocID] = Qry_MPLoc.[LocID];

View 11 Replies View Related

Queries :: Match Based On Multiple Values Within One Field?

Sep 22, 2014

For my study on academic research I need to match patents that refer to academic research as prior work with the actual prior work.

I have two tables (see attached images below).

One regarding AcademicPublications (AP), which is neatly organized with title, year, journal, volume, pages, first author, etc... 480,000 rows

One regarding Patentswhere all this information is hidden within one field, in the most messy way possible... for instance, a field could have:

Quote:

Sugita et al, "Nonsurgical Implantation of a Vascular Ring Prosthesis Using Thermal Shape Memory Ti/Ni Alloy (Nitionl Wire)," Trans. Amer. Soc. Artif. Intern. Organs, vol. 23, pp. 30-34.

or

Quote:

Willingham et al., Cell 13, 501-507 (1978).

Or many other ways.

I want to create a new table that is set up like this:

Patents.PatentNumber | AP.ID | Patents.Reference | AP.Title | AP.Year | AP.Volume | AP.PageStart

The question is: How do I match different fields from one table on one field of another and make it return another field (the ID)? Some references are too horrible to match, but I need as many as I can get.

I can imagine two queries would give me the bulk:

A match in [Title] AND [Year]

A match on ([SourceTitle] OR [AbbreviatedSourceTitle] ) AND [Volume] AND [Year] AND [PageStart]

I understand that I have to make use of the Like "*"&[value]&"*", but how do I make it return the matching ID?

View 10 Replies View Related

Tables :: Auto-Calculate Field From Other Table Values

Aug 10, 2015

How to set up my tables as I'm just starting off with setting my database up.

I'm doing a simple database to track the purchase orders (PO) I am managing. Each PO has a PO Number and an Original Value. POs may have multiple amendments which would change the PO value. I would however like to keep the history of the PO original value and all different amendments.

So I created two tables:

tblPO:
ID
PO Number (Number)
PO Original Value (Currency)
PO Sum of Amendments (???????????)
PO Current Value (Calculated = PO Original - PO Sum of Amendments)

tblPOAmendments:
ID
PO (Lookup from tblPO)
PO Amended Value (Currency)
Amendment Date (Date/Time)
Amendment Desc (Text)

Now the two, million dollar questions are:
1.) Is this the right table structure to use.
2.) How do I go about calculating the Sum of Amendments field?

View 4 Replies View Related

Queries :: Calculate Multiple Fields For One Result - Callsign

Feb 21, 2015

I have never created a single query that is this complicated.

I have a time card database that I created back in 2003 and over the years more and more new task have been added to track volunteer hours has been incorporated into it.

The current task at hand is to determine if each member has achieved or meet certain requirements each year.
They are attend 8 or more meeting and check into 5 or more nets and be Net Control Operator for at least 1 radio net and be involved with 1 or more Public Service events. Sounds simple right?

I have a table that contains all the information that is need to get the result I want but am having a problem getting that result with a single SQL query. Everyone you talk to says use SQL query to obtain calculated vales and never store/save them.

So from the work table below meetings consist of 4,5,6,8,9 and nets consist of 10,11,14,15 and events consist of 2, 13 and the NCOflag is T/F.

So those are all the parts, count the number of meetings, nets, events and NCO and set the meets requirement flag T/F
I keep getting "You tried to execute a query that does not include the in specified expression <name> as part of an aggregate function. (Error 3122)"

In this case it keeps complaining Callsign.

You did not enter an aggregate function in the TRANSFORM statement.

Here's the statement I created:

SELECT [Work Hours].Callsign, [Work Hours].[Work Code], [Work Hours].NCOflag,[Work Hours].SubMtg, [Work Hours].SubNet, [Work Hours].SubNCO, [Work Hours].SubEvnt, [Work Hours].ReqSubTotal
FROM [Work Hours]
WHERE (((Year([Date Worked]))=(Year(Date()))))

[Code] .....

It is failing on the first HAVING (([Work Hours].SubMtg) =Sum(). I have tried many variations and changes but don't see what is wrong with it.

View 2 Replies View Related

Queries :: Rename Field Values With Values From Another Table

Mar 2, 2015

I have two tables.descriptions I'd like to relate and use to find/replace in bulk.

[Checking].[Description] (with the source data)
[Rename].[NewDescription] (with the correct data)

I'd like the values in [Checking].[Description] to be replaced with the values in [Rename].[NewDescription], including those that are "Like".

Examples:
[Checking].[Description] = Geico 12345
[Rename].[NewDescription] = Geico

[Checking].[Description] = Geic
[Rename].[NewDescription] = Geico

View 4 Replies View Related

Tables :: Linking Multiple Field Values To A Field Selected From Combo Box

Feb 16, 2014

I'm pretty good with setting up a very simple database such as inventory, profiles, etc.. However I'm creating a database to keep track of a football (soccer) team's players and match statistics.What I have so farsample attached)

Tables:
* Players - PlayerID, Fname, Lname, position, goals, assists, etc (all details regarding a player)
* Position - Positons (Table containing positions eg: defender. Data is selected in player's form as a combo-box)
* Competition - Competition types (Cup, League, Friendly. Data is selected in Match's form as a combo-box
* Venue - similar to Competition table
* Opponent - Similar to above two tables
* Match - MatchID, Competition, Venue, etc (form corresponding to table attached)

Forms:
* Player form
* Match form

Now as shown in the sample, I choose players using the combo-box. Then whatever stats they had during the match are entered on the fields provided. How to link the player (selected using combo box) to the stat fields (goals, assist, YC, etc).

View 1 Replies View Related

Concatenating Multiple Field Values Into One Field Separated By Commas

Nov 18, 2014

I am trying to create a list of values in a field separated by commas. I have done this in a query as follows:

[Field1]&", "&[Field2]&", "&[Field3] and so on.

However, when Field2 is null, the result is two commas between Field1 and Field2, but I only need one. What function can I use to eliminate the extra commas when fields used in the concatenation are null?

View 10 Replies View Related

Multiple Values In One Field??

Feb 14, 2006

I have a list of Vehicles in which each have their own maintanance schedules. Most of the maintanance for the Vehicles overlap. Instead of entering the same information over and over I'm assigning each type of vehicle a code number (example '05 Cargo is a 1, '04 Cargo is a 2). Now what I want to do is assign each maintanance the vehicle code, for instance I have 13 different types of vehicles that all need oil changes, so I want to assign the Oil change maintanance 13 codes. Is there a way to assign that maintanance 13 codes without having to enter it 13 times??

Thanks, Joe

View 1 Replies View Related

Multiple Values Field

May 7, 2012

Is it possible to have a text field in a table to store multiple values by using a comma or some other type of seperator? I do not want to set the field to a lookup field because the number of values that would be included would be to many to continuously look through to select. I would prefer to just manually type in what I need and use a seperator to create a multiple value field.

View 7 Replies View Related

Adding Up Values From Multiple Queries

Jan 30, 2005

Query 1:
Field #1: User Name
Field #2: CountOfUserName

Query 2:
Field #1: User Name
Field #2: CountOfUserName

Query 3:
Field #1: User Name
Field #2: CountOfUserName

Query 4:
Field #1: User Name
Field #2: CountOfUserName

I want to create a Query that will add
[Query 1].[CountOfUserName]+[Query 2].[CountOfUserName]+[Query 3].[CountOfUserName]+[Query 4].[CountOfUserName]=
[My Query].[TotalCountOfUserName]Group by UserName

It seems difficult.

View 6 Replies View Related

Multiple Field Values In Relationships?

Jan 21, 2013

I have a table for keeping track of software keys This table has all the software keys and an ID field in it.

I then have a table for computers that currently I have it set up so that there is

OSID Field linked to SoftwareID
OfficeID1 Field Linked to SoftwareID
OfficeID2 Field Linked to SoftwareID

On a form I would like it to list ALL software no matter if it is linked or "installed" and show for those that are installed the ComputerID that they are installed on.

Currently no matter how I set it up I can only get it to show the ComputerID for the OS only or for the OfficeID1 only. I want to see if the software is on a computer no matter if it is in the OSID, OfficeID1 or OfficeID2. How do I do that if it is possible?

View 3 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 :: Sum Values Based On Multiple Criteria

Aug 12, 2013

If I want to sum the percentages from April, May and June only if a column is Not Null, how would I do that?

example

Tbl 1
PK, Month
Percent

Tbl 2
FK, Month Enrolled
Qty of Rx in the 1st month enrolled
Qty of Rx in 2nd qtr
Base (if Qty of Rx in 2nd Qtr is null then Qty of Rx in 1st month enrolled)

If Qty of Rx in 2nd QTR is NOT NULL then QTY of Rx in 2nd Qtr * Sum of April Percent+May Percent+June Percent, otherwise Qty of Rx in 1st month enrolled * Month Percent

Im getting stuck on how to sum the percents of April, May and June and then multiplying the result times the Qty ONLY IF the field is not null.

I only know how to create Query's using the design mode. I dont know how to write SQL statements.

View 1 Replies View Related

Multiple Lookup Values Into One Table Field

Apr 4, 2006

Hi,

Is there anyway to have a single field in a table which is populated via the use of a lookup onto another table, but allowing multiple value selection out of the lookup table and populating those into the field...

For example

Table 1 is customer details
Table 1 field 3 = areas of interest

Table 1 field 3 is populated via a lookup into Table 2 interests

Table 2 has 4 records

Sport
Household
Motoring
Family

I want to be able to select 1 or more of the Table 2 values and populate them into Table 1 Field 3....

Help my head hurts....

View 3 Replies View Related

Multiple Field Values Need To Be Returned In ONE Line

Jul 21, 2006

I have no idea if this is possible or not.
I have a requirement to pull a list of Doctor's, their address, and which counties they serve. Sounds fine, right? Well, they want all the counties on one line... One record for each unique address.

So, my query would return this
Dr Address County
Dr Smith Main Street Plymouth County
Dr Smith Main Street Sarasota County

But they want it to look like this
Dr Address County
Dr Smith Main Street Plymouth County Sarasota County

Any idea on how to pull that together for them and put it in an Excel spreadsheet?

Many many thanks.
Tess

View 5 Replies View Related

Queries :: Running Total Multiple Record Values

Mar 21, 2014

I am having an issue with my running total query.

It consists of a running total per vehiclenum. All data comes from one table.

It works properly only on the first vehiclenum of the query. After that, the first "previous" odometer reading of each subsequent vehiclenum starts at some erroneous number, throwing the remainder of each vehiclenum running total.

Here is the code for the query,

SELECT qry_ODO_TotalSub.ID AS OdomAlias, qry_ODO_TotalSub.ODate, qry_ODO_TotalSub.VehicleNum, qry_ODO_TotalSub.Odometer, Nz(DLast("Odometer","qry_ODO_TotalSub","[ID] < " & [OdomAlias]),0) AS Previous, [Odometer]-[Previous] AS Difference, Nz(DFirst("Odometer","qry_ODO_TotalSub"),0) AS StartOD, [Odometer]-[StartOD] AS RunningSum
FROM qry_ODO_TotalSub
ORDER BY qry_ODO_TotalSub.ID;

View 4 Replies View Related

General :: Adding Values (Multiple Entries) In One Field

Dec 6, 2012

I have a field named Supplies Expense. As an analyst inputs a business's expenses, it may require multiple entries into this one field. What is the best way to accomplish this?

For example:

Supplies Expense (Field Name) [$0.00]

The analyst has the following data:

2009 Financial Statement
Paper $50
Depreciation Expense N/A
Ink $100

So, going down the list, the analyst goes into access and enters $50 for paper then later needs to enter $100 for ink.

What is the best way to combine these multiple entries into a single Supplies Expense field and allow for a quality check of the individual numbers at the end of the project?

View 8 Replies View Related

Forms :: Search For Multiple Values In Single Field

Apr 21, 2013

I have a table in which there are approximately 15k records. The name field has approximately 2500 unique values. I need to search the table for multiple names and return the results from the table. This would then be used as a report. Due to the users being very novice, a form is needed for the search.

Example:

Search for Smith, John; Wilson, Bill; Jones, Jeff

Return
Name Year Brand Make
Smith, John 1999 Oldsmobile 88
Smith, John 2001 Chrysler 300s
Wilson, Bill 1994 Porsche Carrera
Wilson, Bill 2007 Kia Sporty
Jones, Jeff 2004 Chevrolet Camaro
Jones, Jeff 2011 Chevrolet Impala

My knowledge of forms is basic, however, I can be a quick learner if on the right track.

View 1 Replies View Related

Allow Multiple Values In Unbound Field For Query Parameters

Apr 30, 2014

I am trying to find a way to allow the user to enter multiple numbers in an unbound box that I will pass to a query as parameters. I already have it set up to pas the parameters from the form but if i try to do more than one number it doesn't work.

I have tried:

1306 or 1307 or 1308
1306, 1307, 1308
"1306 or 1307 or 1308"

I was reading somewhere that when the value is picked up from the form it is not like you are typing it right in the criteria box of the query.

So are there any other options here? Is there a way to enter all the number in a box and then use vba to create an array and then pass that to the query?

View 2 Replies View Related

Query Searching Multiple Tables' Field Names (not Values)

Jan 22, 2007

Hi. Please do not lecture me on database normalization, as this truly is not in my control.

I have 2 dozen tables, each with 13 fields. All of the field names exist in at least 12 of the tables. And all tables share a ssn field where values are common.(Confused yet? Sorry, if you are...)

If I design a query showing all 2 dozen tables and their fields...
Can I set up a query criteria where I enter the requested ssn and then the required field name and have the result show the values of all the fields with that name, among the ones of the 2 dozen tables where that field name exists? (for that specified ssn)

If I am only as clear as mud, please let me know, and I will try again.
Or, by asking if I can search for field values querying by field name, am I any clearer?

Russ

View 14 Replies View Related

General :: Add Return Between Entries In Form Field That Allows Multiple Values

Apr 5, 2013

I have a subformClientOffers on my frmAllProperties. On the subformClientOffers is a field called Outside Agents. This field allows for multiple values to be selected.

The subfrmClientOffers is in datasheet view.

While the field Outside Agents DOES allow me to select more than one, they post in the field one after another:

Ken Shaw, John Doe, Jane Doe, Harlan Bestlyn

Therefore, the datasheet view of the subformClientOffers causes the field Outside Agents to get very long, much too long to view without scrolling. My client wishes for everything on the frmAllProperties to be viewable without scrolling.

Is there anyway, to cause the field Outside Agents to place a return between each selected name (sort of a wrap text kind of thing)?

One thing I might mention is that the field is a drop down field from tblOutsideAgents. The table itself has First Name and Last Name, but I concatenated that into Fullname on the form, so that when the user opens the drop down they see the entire name. I don't know if that would have any effect on making the 'return' thing work or not.

I can't use this field as a subdatasheet because I already have one subdatasheet attached to the subform to show multiple notes on each Client Offer.

View 4 Replies View Related

How To Handle Multiple Null Values Using Form-based Parameter Queries

Nov 19, 2012

i'm creating a search form giving the end user a range of controls to use when filtering/searching data. See the image.But, i think my range search (using the textbox) to put in a lower and upper limit...is preventing this from working. In fact, when i put data into all the controls, no data pops up in my subform.

My query data source can also be seen...showing you how i've handled teh null entries. (i need to put in a null 'handler' for the two textboxes?)

View 2 Replies View Related

General :: Form Control To Combine Multiple Field Values Into A Single Text Box?

May 10, 2013

I'm trying to set the control source for a control on my report that describes the number of portions that goes into a box. Sometimes there is a specific number of portions per box and sometimes it's a range. When the number of units is specific, then it is entered into the MasterCaseMinUnits Field. If there is a range of units possible than the min is entered into MasterCaseMinUnits and the max is entered into the MasterCaseMaxUnits.

I want my report to look at the mastercasemaxunits, if it is blank it will only display what is in the MasterCaseMinUnits field. If there is a value in the masterCasemaxUnits field, then it will display the masterCaseMinUnits & " - " & MasterCaseMaxUnits. this is the code I'm Using:

Code:

=IIf(Nz([MasterCasemaxUnits],[MasterCaseMinUnits])=[MasterCaseMinUnits],[MasterCaseMinUnits],[MasterCaseMinUnits] & " - " & [MasterCaseMaxUnits])

When I run my report, the control displays: #Type!

View 2 Replies View Related

General :: Summary Form / Home Page - Text Boxes Values From Multiple Queries

Jan 20, 2014

I am currently developing a database to provide a friend with an auction tracking and ordering system.

I will have a number of questions the first is related to the Home Page/Dashboard/Summary form I am creating. I basically have a few sections, one of which is a combo box offering the user to select an auction to view in the summary section. This summary section contains the list of lots but I also hope to to expand on this and create multiple text boxes, each containing the answer to a number of queries (totals etc).

I have written all the queries and can see the results however as the form does not have a record source I would like to know how to make each text box populate with the result of different queries (ideally in vb - I am using ms access 2010)?

I have tried a few things, control source doesn't apply as I have no record source (i guess). I investigated Dlookup/Dcount but am unsure if these apply for the same reason. I understand I am likely to need a recordset etc in vb and have already tried a few things but unfortunately none of them work.

View 1 Replies View Related







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