Queries :: Value From Column Based On Value In Field

May 14, 2013

Is Access SQL able to do this:I want the value from a particular column, whose name is derived from the value in the field of another column?

Eg.
Col1 Col2 Col3 Col4 Col5
1 ABC 234 Col2 ABC
2 BCD 345 Col3 345
3 CDE 456 Col2 CDE
4 DEF 567 Col2 DEF
5 EFG 678 Col3 678
6 FGH 789 Col2 FGH

As you can see, I want the value in column 5 to be derived from the value in Column 4.Is this possible to be done in SQL.

View Replies


ADVERTISEMENT

Queries :: Change In Column Based On Base Query Column

Mar 24, 2014

I have created a cross tab to extract pipeline and sales for Q1 2014, Q2 2014, Q3 2014 & Q4 2014... the user can select the quater from a multivalued text box...

Now for the final output, have created another query which pull the above four quarter in each column from the cross tab...now the problem arises when i change the quarter to Q2 2014, Q3 2014, Q4 2014 & Q1 2014..it gives an error "Microsoft office Access database does not recognizes "Query name" as a valid field name or expression".

The error is because the second layer of query does not identifies Q1 2014.

How do i make access change the column automatically when the Q1 changes to Q2...

View 1 Replies View Related

Queries :: How To Return Value Based On Row And Column Location

Aug 9, 2013

I inherited a spreadsheet that uses an Index (Match formulate to return a value. I want to use Access to manage the data going forward. I am just starting to build my tables in Access so I have some flexibility and want to do it right. Here is a sample of the data:

KeyEnroll JanFebMarAprMay
abc1/2013103521
def3/201300789
ghi5/201300008

So if Enroll date starts in Jan I want the 10 amt returned from the Jan column. If the Enroll date starts in March, for that client I want the March amy returned, etc.

results: for client "DEF" the amt returned should be "7" because their enrollment date is 3/2013.

View 4 Replies View Related

Queries :: Change Query Column Name Based On Text Box Value

Nov 8, 2013

Is there a way of using a text field value as the heading for query column?

ie change...

Column header: FieldInATable

to

[form1].[field2]: FieldInATable?

View 1 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

Auto-fill Based On A Field Other Than Bound Column?

Feb 9, 2015

Access 2010. The first table is called Clients.The Primary Key field for the Clients table is an AutoNumber field called ClientID.The other two relevant fields in this table are ClientFirstName and ClientLastName. The second table is called Contacts.In the Contacts table is a foreign key field, bound to the ClientID field from the Clients table, and also named ClientID.

On the Contacts table, the ClientID field properties are set on the Lookup tab as follows:

Display Control: Combo Box
Row Source Type: Table/Query
Row Source: SELECT clients.ClientID, clients.ClientFirstName, clients.ClientLastName
Bound Column: 1

Further, in the Row Source's Query Builder, ClientFirstName and Client LastName both have Ascending selected as Sort criteria.

Everything works as intended: When entering data into the the Contacts table (actually, the data is entered via a form built from the Contacts table) the data entry person can click the drop-down on the combo box for the ClientID field, scroll through ClientID records, and see unique ID numbers sorted by first and last names. And the actual data for the field is stored properly as the unique ClientID number.

When entering ClientID data into the Contacts table (or form), is it possible to enable autofill based on ClientFirstName and ClientLastName, rather than ClientID? For instance, let's say we have a few clients named Joe Smith. It would be great to just start typing "Joe Smith," and have the field autofill the ClientID number for the first client named Joe Smith. The intention is to make data entry a bit quicker.

View 3 Replies View Related

Queries :: Updating Column With Various Results Based On Other Record Values

Jul 11, 2013

I have a field called density which needs to be updated to show either 10, 20, 30, 40, 50,60, 70 or 80 depending on a number of variables, for example: If market location is 'hot' and unit type is 'house' and discounted is 'no' then show '10' in the density box.

or perhaps:

If market location is 'cold' and unit type is 'apartment' and discounted is 'no' then show '20' in the density box.

I have tried all sorts of expressions and queries but have really reached the limit of my know how and can't solve it. Is it even possible to do this in Access?

View 2 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

Auto-fill A Field Based On Previous Filed Within Same Column

Feb 9, 2012

How do I get access to auto fill a text (supplier)? I realize that for a new supplier I would have to input the supplier name, however my question is what should I do for Access to enable auto-fill so that the next time I have to input that supplier it would auto fill for me. This is happening in a single column.

For example: In the supplier column, I typed Dell in the first row, Apple in the second row, HP in the third row. Now when I start typing 'Apple' in the fourth row, I want it to autofill 'Apple' because I have already input that once.

View 7 Replies View Related

Queries :: IIF Statement Expression - Create Alias Column Based On Data From Two Fields

Jun 20, 2013

I am writing a very complex 'if statement' query expression. I need to create an alias column based on data from two data fields.

Here's the logic:

True: If [PP] = "WG" or "WS" or "WL" and If [GR] > 10 Then "Skilled" or
[GR] Between 6-9 Then "Semi - Skilled" or [GR] <6 Then "Unskilled"

False: "GS"

View 2 Replies View Related

Populating A Column In A Table Based On Values In An Existing Column

Mar 5, 2007

Hi all,

In the organisation that I work for employees get paid every 2 weeks on a Saturday. So for this financial year the pay period end dates have been 08/07/2006, 22/07/2006, 05/08/2006 etc


I have a column in an Access table listing various dates. I want the next column to be
populated with the next pay period end date after that date.

So if DATE is 05/07/2006 I want PAY PERIOD END to be 08/07/2006
and if DATE is 09/07/2006 I want PAY PERIOD END to be 22/07/2006 etc

How do I do this?

Kind Regards,

Matthew

View 1 Replies View Related

Modules & VBA :: Input String In Column Based On Data In Another Column?

Nov 30, 2014

I need to input a string into a column named "EventType". The code should first check if the column "Agent Name" contains any strings. If there is none, it will input "IBM Director" into the EventType column.

Once it has looped through the agent names, the code will then loop through the Details column and input into EventTypes based on what is displayed within the string.

These are the codes that I am using to achieve this, however nothing is being input into the EventType column.

Code:
Private Sub Command11_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Final")

[Code] ....

I think the problem lies with the code that checks the agent name. When I removed it, it managed to populate the EventType column based on the details. But I still need to find out how to check the agent name too.

View 4 Replies View Related

Queries :: Turning Column Names Into Field Values?

May 7, 2014

I have a spreadsheet which contains data exported from another system (which I have no control over). I'm using this spreadsheet as a linked table in my database.

The problem I am having is that I can't guarantee that when the spreadsheet is updated, it will contain the same column headings as it did the last time...

The spreadsheet contains a list of temps, with a summary of info off their submitted timesheets. So the column headings (as well as WorkerName, TimesheetDate, etc) may be "Standard Hour", "Overtime Hour", "Over 12 hrs Hour", "Standard Day", "Overtime Day", etc - for each type there will be a Pay Rate and a number of units (hours or days) claimed. The columns only appear if 'someone' in the spreadsheet has claimed something under that heading this week.

What I need to do is to produce a report which gives a summary by person and week of the number of hours claimed and the total charge. I've done that - that part was easy The part I'm struggling with, is how to take the column headings and turn those into descriptors for each charge type... in otherwords, to go from the sample 'timesheet' below to the sample 'ByType' ?

... when I don't know which columns will be present each week?

At the moment I'm using a union query to pull out the info I need, but if the column headings change then I know it will stop working...

sample of my union query... I currently have 8 different sets of bill rate and charge rate, this just does the first couple...

Code:
SELECT qryTimesheetBaseData.[Time Sheet Start Date], qryTimesheetBaseData.[Time Sheet End Date], qryTimesheetBaseData.[Cost Centre], qryTimesheetBaseData.Worker, "Standard" AS RateType, "Hourly" AS RateCategory, qryTimesheetBaseData.[Bill Rate (ST/Hr)] AS Rate, qryTimesheetBaseData.[Time Sheet Billable Hours (ST/Hr)] AS Billable, qryTimesheetBaseData.[Time sheet Status] AS Status

[Code] ....

View 3 Replies View Related

Queries :: Field Header In Query Based On Other Field Data

Jun 28, 2013

I have two tables that are joined - called A and B. A has two fields, "PLACE" and "RAND" and is joined to B via field "RAND". Other than "RAND", B has several fields named 01 TOTAL, 02 TOTAL, 03 TOTAL, etc...for about 60 fields.

The "PLACE" field in table A has data that is 01, 02, 03, ect.... How do I structure a query so that whatever "PLACE" is, I can match the XX TOTAL value? In other words, i need to have the query field header be somehow dependent on the value in "PLACE".

Is this even possible?

View 4 Replies View Related

Queries :: Field Appears Multiple Times But Different Criteria For Each Column

Jun 2, 2013

I'm working with a table of bird survival data I am trying to summarize in a query. I've got a bit of a roundabout way to achieve my goal, but I'm curious if there is a simpler approach.

Background : In my table, each row represents a day I check a given nest and includes a [Nest ID] (not unique, multiple visits to each nest), a [visit ID] (auto numbered, so it's a unique value for each visit at each nest), the calendar day I visited a nest [Date], and [Survive] (1 or 0) depending on whether a nest survived or failed.

I'm trying to convert this detailed table into one that is more concise. Instead of each visit to a nest being a row, each nest becomes a row with 4 fields: The Nest ID, the minimum date (the day I found a nest), the last day a nest was checked (Max[Date]), and the last day a nest was checked alive (essentially max date where survival=1).

My current solution is to run 3 separate queries. The first queries the max date where survival=1, the second queries the max and min dates regardless of any other criteria, and the third brings both queries together.

I am curious if there is a way to create the same final product in a single query rather than doing multiple ones as I have done?

View 3 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

Queries :: Two Tables To Result In Single Column With Field Name Identifier For Each Record

Apr 27, 2015

How to get this one to display in a single column.

I know how to do this wiht VBA. But, this output will need to reside on a SQL Server View. So I need a SQL language solution. If it can work in MS Access Query, it won't be too difficult to test then translate to SQL Server.

Customer Table with PK Customer_ID.

There are two tables with FK Customer_ID.

1. Table Lease1 - Has 3 Fields - the form code enforces No Fields -or All Fields. The red * indicate a Required field - These 3 are entered together.

2. Table Lease2 - Has 1 field with 0 to Many records.

Goal:

The Type shows up in a single column.

Each Type shows where the data comes from (Lease Type, Surface Owner, Mineral Owner, or Hz Lease Type)

Challenge:

Lease1 table has 3 fields that need to be transformed into a single column.

Lease2 table has 1 field to be appended to the single table.

Then, there is the column that identifies where the data came from based on the column name.

View 6 Replies View Related

Queries :: Showing A Field Based On Another Field

Jul 8, 2014

I was wondering if it is possible to determine weather to show a field based on the values from another field.

Field1, SHOW_Field1, Field2, SHOW_Field2
Field1 and Field are text, SHOW_Field1 and SHOW_Field2 are Boolean values

So if SHOW_Field1 is true, then show Field1 in the query else hide. I was wondering how to do this, I seem to not be able to do this for some reason.

View 3 Replies View Related

Queries :: Run A Simple Update Query To Copy Data From One Column To Another Column

Sep 24, 2013

I am trying to run a simple update query to copy data from one column (Addrl1)to another column (Working_Addrl1) within the same file and I can't for the life of me figure it out. Then I need to repeat for addrl2 and addrl3 to working_addrl2 and working_addrl3.

View 7 Replies View Related

Queries :: Find Unmatched Contents From The Column By Matching With Another Column?

Nov 16, 2013

i have a columns as 1. contactname, 2. firstname 3. lastname 4. email and in this columns some emails are not matching with the contactname or some time firstname or some time lastname so i need the to find out the un matched contacts from the database.

View 1 Replies View Related

Queries :: Update In Table From Same Table Based On Criteria Column In Same Table

Sep 29, 2013

How can I update (some columns) in a table from the same table based on a Criteria column in the same table.

View 2 Replies View Related

Queries :: Sum Based On Partial Field?

Aug 1, 2013

I'm trying to build a query that groups data by a code that is six digits. however, I only want to consider the first 4 digits when grouping by. (ex. table has code 100023 and I only want to group by 1000). Is there a way to do this within a query instead of modifying the table itself?

View 1 Replies View Related

Queries :: How To Sum Field Based On Every Year

Jul 2, 2015

I tried writing a SQL query to produce the list of details in year wise DESCENDING order for the input - Agent ID.

In addition to that I need to get the sum of amount fields year wise in the report. How to achieve it???.

Find the attached report for better clarification.

First three column in the attachment is the outcome of the below listed query. Whereas the fourth column is the expected result which needs to be included..

Code:
SELECT CessioneCredito.Data_Movimento, CessioneCredito.Anno, CessioneCredito.Importo FROM CessioneCredito
WHERE (((CessioneCredito.ID_Agente)=[Reports]![R_StoricoCessCredAg]![ID_Agente]))
ORDER BY CessioneCredito.Data_Movimento DESC;

How to alter the code in order to provide the SUM of Importo field every year.???

View 3 Replies View Related

Queries :: Add A Column In A Query That Will Give Y Or No To Previous Column

May 21, 2015

I am looking to add a column in a query that will give a Y or No to previous column data if it contains TEXT or NUMBER (It could read "TEXT" or "NUMBER" or even Y for text or N for number).

View 3 Replies View Related

Queries :: How To Distribute Different Values Of One Column In New Column Fields

Jan 30, 2014

In my table for duplicate "line no" I have different "contractor" like below.

LINE NO CONTRACTOR

L-0001 C-1000
L-0001 C-2000
L-0003 C-6000
L-0003 C-8000
L-0003 C-9000
L-0004 C-5000

Now I would like to make a query for transposing values like below:

LINE NO CONTRACTOR1 CONTRACTOR2 CONTRACTOR3

L-0001 C-1000 C-2000
L-0003 C-6000 C-8000 C-9000
L-0004 C-5000

how I have to make this query?

View 1 Replies View Related

Queries :: How To Replace A Field With A Different Word Based On Its Value

Mar 15, 2013

I have a seating chart with 33 tables. Under each table there is a number that represents seats taken. I want to do a query that changes the number when it is a certain value. For example, when the value is null I want it to say "Empty", when the value is 10 I want it to say "Full" and when the value is over 10 I want it to say "Over". If the value is 1-9 I want to leave it as is.I know how to accomplish one at a time but not all three together. I've been useing:

Nz([Table#],"Empty")
IIf([Table#]=10,"Full",[Table#])
IIf([Table#]>10,"OVER",[Table#])

[code]....

View 6 Replies View Related







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