Queries :: Selects Active Records For Three Different Selections - Concatenate Query Results

Nov 3, 2014

I have a query that selects the "Active" records for three different selections, A, B or C.. There may be 1, 2 or 3 results for a particular selection. That is Selection A may have one result or active records, but Selection B may have three results.

I want to use data from the query to populate a field on a form. For example, if the results for Selection A, having one "Active" record would be RecordAData. But for Selection B with three "Active" records the result would be RecordBData & " " & RecordBData2 & " " & RecordBData3

My query is:
SELECT tblSomething.ID, tblSomething.D1, tblSomething.D2, tblSomething.D3, tblSomething.D4, tblSomething.D5, tblSomething.D6, [D3] & " " & [D4] & " " & [D5] & "-" & [D6] & " " & "SomeText" AS Header
FROM tblSomething
WHERE (((tblSomething.D1)=Forms!frmSomethingHeaders!D1) And ((tblSomething.D2)=True));

The concatenation in the query is labeled "Header". I want to be able to Concatenate the "Header" which in itself is a concatenation in the query.

I thought that this might be a looping through the query results, but I cannot figure out how to do it. But then, that is only my uneducated guess.

View Replies


ADVERTISEMENT

Queries :: Transpose And Concatenate Query Results

Jul 24, 2014

I am trying to generate a simple report that can be imported to excel for analysis. Currently the database documents failure causes associated with a repair. I need a "Report" that does not duplicate the failed items in the event there is more than one cause associated with the failure. some repaired items may have up to 3 causes of failure. What I would like to do is have the query show one record instead of three records (for the cases were three causes of failure were identified for a repair)

Current query format

Code:
facilityID Failure Cause
1 Electrical Surge
1 Mechanical Wear
1 Corrosion
2 ......
2 ......
.... ......

Desired query format

Code:
FacilityID Failure Cause(s)
1 Electrical surge, Mechanical wear, Corrosion
2 .....
.... .....

I was reading about a SQL transpose call but I do not need all fields transposed (only the failure causes transposed and concatenated into one field).

Test database attached with a query that shows the data I want to transform into the desired format.

View 6 Replies View Related

Queries :: Query Selects Records Twice

Aug 22, 2013

why this query pulls every record twice and what I can do to fix it?I did it in design mode because I'm an amateur, but here is the SQL.

SELECT [Patient Data Table].[First Name], [Patient Data Table].[Last Name], [Patient Data Table].[C MRI Facility], [Patient Data Table].[C MRI Sched Date], [Patient Data Table].[C MRI Scan Done]
FROM [Patient Data Table], [Date Range]
WHERE ((([Patient Data Table].[C MRI Scan Done])=Yes) AND ((Month([C MRI Sched Date]))=[Date Range]![From Month]) AND ((Year([C MRI Sched Date]))=[Date Range]![From Year]));

View 6 Replies View Related

Queries :: How To Write A Query Which Selects Multiple Records From A Table At Once For Updating

Aug 14, 2013

I have a list box whose data is inserted in a table named as "test0" ,now in a macro of vba i want to select all the items in the list box and create there pdf files in a folder at my desired location. So far i have managed to create a pdf file of single item ,but i want to select multiple items at once ,

Code:
SELECT test0.ID, test0.item FROM test0 WHERE (((test0.item)=[ItemNumber]));

So, in this query itemNumber are multiple and i want to create there pdf files at once ..just on a click of one button ?

View 2 Replies View Related

Concatenate Results Of A Single Column Query

Mar 14, 2007

I have a query which select the records who have a certain criteria.

The result is something like this.
A 0012345
A 0032432

Note that the records that have this criteria will be smaller or equal than 2.

I want the query to give me this answer instead.
A0012345, A 0032343
(in the same field that is).

Is this possible, if so can someone help me. My email address is russcami@yahoo.com

Thanks

View 2 Replies View Related

Query Selects No Records, How To Convert Null To Zero

Apr 29, 2008

Simple query, but I need to roll the results up with others and a null return is hurting me. I have been chasing my tail around with the nz(), input masks, IIF statements, only to prove my ignorance and possible insanity for expecting different results.

Here we go:

SELECT Count([LDB LOG].DSTHTL) AS ["tot120"]
FROM [LDB LOG]
WHERE ((([LDB LOG].[LDB Rcvd]) Between Now()-120 And #1/1/2008#))
GROUP BY [LDB LOG].[T-7 Date]
HAVING ((([LDB LOG].[T-7 Date]) Is Null));

This is being used to count open items into age buckets, the above is the greater than 120 days (discounting anything prior to 2008). If the T-7 Date is null the item is open. What is happening is that no records are being selected, resulting in the null value back.

Any help would be greatly appreciated as I have spent an unrealistic amount of time on this.


Thanks
Brendan

View 6 Replies View Related

Queries :: Concatenate Multiple Records Grouped By Date?

May 2, 2014

I have a rates table with 3 fields : [RateDate], [CurrencyID], [FXRate]

I also have a currencies table with 2 fields : [CurrencyID], [CurrencyCode]

Where [CurrencyCode] is just the 3-character currency code (i.e. EUR, GBP, USD etc.)

The rates table uses a composite primary key across [RateDate] and [CurrencyID] - i.e., there should only be one unique record for each combination of date and currency.

Not every date will be present in the table and, within each of those dates, not every currency will be present (but at least one, obviously)

I want to write a query which will return two fields. The first field will contain all of the unique dates in the table for which the [FXRate] field (for any currency) is blank / null. Straightforward enough :

Code:
SELECT [tblRates].[RateDate]
FROM [tblRates]
INNER JOIN [tblCurrencies]

[Code]....

But this gives me a separate record for each date / currency combination in the returned dataset. I just want one record per date and all of the currency codes in a single string (separated by some delimiter) as a text field.

View 3 Replies View Related

Queries :: Duplicate Results For Some Of Records In A Query

Dec 3, 2013

Why I am getting duplicate results for some of my records in a query. I have unique values set to Yes. I have also validated that the tables I am using don't have duplicate data. SQL is below.

SELECT DISTINCT [tbl_Rewards Activity Report - By Member Number].[Member Number],
[tbl_Rewards Activity Report - By Member Number].[Last Four],
[tbl_Rewards Activity Report - By Member Number].[BAL ID],
[tbl_Rewards Activity Report - By Member Number].[Primary Name],

[Code] .....

View 1 Replies View Related

Queries :: Concatenate Related Records Into One Expression / Field In A Form

Feb 13, 2014

In my query, I have several results that relate to the same PK overall, and I'd like to concatenate these records into one expression/one field in a form.

Currently my query looks like this;

As you can see, the BandPK/BandFK are repeated where the GenreFK/GenrePK are different. What I'd like to do is concatenate the column named Genres into one field so the BandFK/PK isn't repeated.

View 14 Replies View Related

Queries :: Records Active ON Or AFTER A Specific Date

Nov 26, 2014

I have a query from a table (to reduce the number of fields).The list is all the positions people have performed, as person could have one record another could have 10 the number is unlimited.

Fields are:-
-employee ID
-start date
-position

I need to find any records that were active ON or AFTER 01/09/2014. This will be 1 record for most but some could have multiple.I think it makes it more difficult that there is no END DATE.

View 6 Replies View Related

Queries :: Deleting Records Based On Selections From Another Table

Apr 1, 2013

I am trying to create a Delete query.

I am trying to delete a specific part from multiple BOMs in my database.

I have a table of the BOMs that I want to look in. I called this table PartTable. I also linked my database table SYSADM.REQUIREMENT which contains all the requirement parts for all of our BOMs.

So I am wanting to delete only part number 123XX from each of the BOMs in my PartTable.

I am able to select the records with:

Code:
SELECT SYSADM_REQUIREMENT.*
FROM SYSADM_REQUIREMENT INNER JOIN PartTable ON SYSADM_REQUIREMENT.WORKORDER_BASE_ID = PartTable.PART_ID
WHERE (((SYSADM_REQUIREMENT.WORKORDER_TYPE)="M") AND ((SYSADM_REQUIREMENT.WORKORDER_BASE_ID)=[PartTable].[PART_ID]) AND ((SYSADM_REQUIREMENT.WORKORDER_LOT_ID)="0") AND ((SYSADM_REQUIREMENT.PART_ID)="123XX"));

Now how do I delete these same records.

I am getting error saying I have to select a table to delete from....

View 11 Replies View Related

Queries :: Use Query Results To Fill In Records In Another Table

Aug 18, 2015

I have a query that outputs results like:

Company ID | Data A | Data B | Data C

101 | results |results |results
102 |results |results |results
103 |results |results |results
104 |results |results |results
105 |results |results |results

In another Table containing additional company information, I have the primary key as the company ID, and I want to make the query that outputs the above table, auto-fill the blank fields in the existing Company information with the same headings as Data ABC etc.

However, I don't want the query to add full new records (which I think is the Append Query?), instead I want the existing company records have additional fields (Data ABC) added, with information from the Query added.

View 1 Replies View Related

Queries :: SELECT Query Results Inconsistent - Not Getting All Records

Jun 20, 2013

I have a simple select query on a SQL table from Access. The query is:

SELECT tbl_Orders.OrderID, tbl_Orders.Approved
FROM tbl_Orders
WHERE (((tbl_Orders.Approved)=0) AND ((tbl_Orders.Completed)<>0))
ORDER BY tbl_Orders.OrderID;

The strange thing is that sometimes it pulls 34 results, and sometimes 38. From what I can tell, it should be pulling all 38.

What can I do to make sure it gets all the records?

View 2 Replies View Related

Queries :: How To Concatenate Row Values Using A Query

Jul 1, 2013

I have a table Pmt in Ms Access with following information:

Table Pmt
Cust no Inv no T no Date Amt
123 ABC T1 20110131 1000
123 ABC T2 20130228 1000
123 ABC T3 20130331 1000
789 XYZ A1 20130131 2000
789 XYZ A2 20130228 2000

Fields "Cust no", "Inv no" and "T no" are in Text format, whereas "Date" and "Amt" are in Number.

My question: how can I concatenate row values using a query. The query results that I wanted are as follows:

Cust no Inv no T no Date Amt
123 ABC T1, T2, T3 20130131, 20130228, 20130331 3000
789 XYZ A1, A2 20130131, 20130228 4000

View 2 Replies View Related

Multiple Selects And Records Store

Dec 21, 2005

I'm creating an Access data entry form for computer installations.

Basically the entry form will choose a software and license, then select one or more computers to install the software on.

Then later we can create a report that can track what softwares are installed on the computers, or track what computers has what softwares.

Now my question is for each record of the installation entry form, after we select the software, then we will choose a computer name or more computer names.
If just one computer is easy, but how can I choose multiple computers, which control should I use? and how can I store the computer name list in the installation table, do I have to make each computer installation a record in the table or put multiple computer names in one record in the field like memo, but if I use memo, later it seems i cannot group or search memo field?

Can anyone give me some ideas about what is an easy design solution or samples about these?

Thanks a lot

View 1 Replies View Related

Queries :: Copying List Box Selections Into Append Query

Dec 15, 2014

I've got a listbox on one of my forms (with multi select enabled). Essentially its a list of products, the idea is for the user to select as many products as he or she likes, then they click a button and the selected products show up in an append query, which will add records to a table.

How to copy the data from a list box to an append query (nothing that each selection should have its own row)...

i also wanna look into "Select All" and "Select None" buttons, is this possible?

View 4 Replies View Related

Queries :: Concatenate Field Data Into One Cell In Query According To Linked Table ID?

Mar 8, 2014

i need to Concatenate a fields data into one cell in a query according to linked table ID....

View 3 Replies View Related

Queries :: Select Active Record In A Table Using A Query

Nov 30, 2013

Based upon a specific date (varDate), I want to select the record that is active (who drives the lease car).

row 1 user X from 13/11/2013
row 2 user Y from 15/11/2013
row 3 user Z from 17/11/2013

I want to find the active user on a date. So on date 13/11/2013 (=varDate), user X is active, on 14/11/2013 (=varDate), user X is still active, on 15/11/2013 (=varDate), user Y is active, on 16/11/2013 (=varDate), user Y is still active and on 17/11/2013 and later, user Z is active.

View 1 Replies View Related

Modules & VBA :: Connect Datasheet Form To Active Directory Search Results

Jul 31, 2013

I'm trying to tie a from into the results from and AD Query. I'm not that experienced with doing this kind of thing so I may be going about this the wrong way. Anyway here's what I've got so far:

Code:
Private Sub Form_Open(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
With cn
.ConnectionString = "Provider=ADSDSOObject;Trusted_Connection=yes;"

[Code] .....

When stepping through the code, it all goes well until it hits the line that actually connects it to the form "Set Me.Recordset = rs".

When this line is executed, Access crashes and attempts to restart.

PS: Access 2010, Win7 64bit

View 5 Replies View Related

Queries :: Number Of X Results In Last Y Records

Jul 29, 2014

I have a table with:

A dDataID (sequential auto-number)
B dDateTimeEntered (date/time field)
C dFactoryOrder (text)
D dSpecificationID (number)
E dStartWeek (text)
F dIncreasingDecreasing (text, values are limited to "Increasing", "Decreasing", or "NA")

I need a query to look up the last 9 values where C, D, and E match variables from a form, then tell me how many "Increasing" values are contained within that set. I want to store the final value in a combo box on the form. I tried writing the code and this is what I got - design view attached as a pic and SQL below. It looks like the "Top 9" is sorting on the Expr1 field, which isn't what I want, but I'm not sure how to force it to use dDataID or dDateTimeEntered to figure out which records to use.

SQL:
SELECT TOP 9 Sum(IIf([tblData]![dIncreasingDecreasing]="Increasing",1,0)) AS Expr1
FROM tblData
WHERE (((tblData.dFactoryOrder)=[Forms]![frmDataEntryDisplay]![dFactoryOrder]) AND ((tblData.dSpecificationID)=[Forms]![frmDataEntryDisplay]![dSpecificationID]) AND ((tblData.dStartWeek)=[Forms]![frmDataEntryDisplay]![dStartWeek]));

View 8 Replies View Related

Query Which Selects Fields?

Mar 17, 2007

Is it possible to create a query which selects selects fields in a table, not just data in a field? If so, how?

TIA

View 1 Replies View Related

Queries :: Excluding Records From Search Results That Have Fields With No Data?

Aug 6, 2015

I have a search form with 12 fields. In my query I use

Code:

Like "*" & [Forms]![CustomerRetestDatabaseSearch]![RetestLocation] & "*" Or Is Null

for each field on the search form.

I get the results I expect, it finds all records that match the criteria. Even if some of the fields in a record are null.

But if the query finds a record that matches one field I enter criteria into, and nulls for the other fields I enter criteria into it displays the record. I want to show exact matches. (If what I entered is null... don't show the record).

The reason I have "Or Is Null" is to include the records for the fields I left blank on the form.

Search Form with Criteria.PNG

Search Query.jpg

Search Results With Missing Entered Criteria(Dont Want These Records Included).jpg

View 2 Replies View Related

Multiple Selects In An Access Passthru Query

Sep 7, 2005

Hi,

I'm trying to run a pass thru query into a sybase server from Access. The query contains multiple selects which Access doesn't appear to like very much. The query works fine when run in Sybase.

Is there any way of circumventing this problem?

I could split the three selects into three seperate queries to view the individual results but the third set is dependant on the previous two sets and so therefore is difficult (impossible?) to seperate out as a third individual query.

Thanks for any suggestions?

Select
s.id_prtf Portfolio_ID,
s.id_imnt Instrument_ID,
s.id_imnt_swap Instrument_Swap_ID,
s.id_ccy_std Currency,
s.am_posn Position,
s.am_pnl_eqty PNL_Eqty

into #temptable1
from
SET_VALUATION s, INSTRUMENT i
where
s.id_imnt = i.id_imnt
and s.id_posn_ref is NULL
and s.id_imnt_swap is NULL
and s.am_pnl_eqty > 0
and i.id_typ_imnt != 'SFX'

Select
s.id_prtf Portfolio_ID,
s.id_imnt Instrument_ID,
s.id_imnt_swap Instrument_Swap_ID,
s.id_ccy_std Currency,
s.am_posn Position,
s.pr_imnt_mtm_prev,
sy.pr_imnt_mtm,
s.am_mv_prev,
sy.am_mv

into #temptable1a
from SET_VALUATION s, SET_VALUATION_HIST sy, REFERENCE_DATA r
where
s.id_prtf = sy.id_prtf
and s.id_imnt = sy.id_imnt
and s.pr_imnt_mtm_prev != sy.pr_imnt_mtm
and s.am_mv_prev != sy.am_mv
and r.dt_bus_lst = sy.dt_bus

select
t.*,
tt.pr_imnt_mtm_prev,
tt.pr_imnt_mtm,
tt.am_mv_prev,
tt.am_mv

into #newtemp
from #temptable1 t, #temptable1a tt
where
t.Portfolio_ID = tt.Portfolio_ID

delete from #temptable1
where #temptable1.Portfolio_ID in (select Portfolio_ID from #newtemp)
delete from #temptable1a
where #temptable1a.Portfolio_ID in (select Portfolio_ID from #newtemp)

select "Where id_posn_ref is NULL and id_imnt_swap is NULL is the only criteria"
select * from #temptable1
select "Where SET VAL's pr_imnt_mtm_prev does not equal SET VAL HIST's pr_imnt_mtm, is the only criteria"
select * from #temptable1a
select "Where the output satisfies both Where id_posn_ref is NULL and id_imnt_swap is NULL AND Where SET VAL's pr_imnt_mtm_prev does not equal SET VAL HIST's pr_imnt_mtm"
select * from #newtemp

drop table #temptable1
drop table #temptable1a
drop table #newtemp

View 2 Replies View Related

Concatenate Multiple Records Into Memo Field

Mar 9, 2007

Hi All,

I can use some help with a jumping off poit.

*Please see attached file*

I have 2 tables tblSFDC and tblTheCall

tblSFDC (contact information) includes CustID (primary key) and a memo field "Notes"

tblTheCall (call information) includes CustID (relates to tblSFDC) and "activity data fields" ie "Live", Left Message" , Sent email".

tblTheCall may in some cases have multiple records for each CustID

I need to :
Concatenate from tblTheCall Field Names and field values (that are not null)
Insert into tblSFDC.Notes
Where tblTheCall.CustID = tblSFDC.CustID

*Please see attached file*
TIA
Detrie

View 8 Replies View Related

Combine / Concatenate Multiple Values In Different Records That Have Same ID

Mar 13, 2012

I have to concatenate the data in multiple records into one record. They have "skus" associated with them.

I have two columns.

ColumnSku: Which contains a product sku
ColumnModel: Which contains a model numbers

ColumnSku can contain the same sku hundreds of times
ColumnModel can contain the same model several times but not for the same sku

What I need to do is this: For every time a sku is shown in ColumnSku, take the model in ColumnModel and join them together separated by a comma.

For example

ColumnSku|ColumnModel
SKU1111|Model11111
SKU1111|Model22222
SKU1111|Model33333
SKU1111|Model44444
SKU1111|Model55555
SKU9999|ModelHHHHH
SKU9999|ModelJJJJJ
SKU9999|ModelMMMMM

Would end up like this
ColumnSku|ColumnModel
SKU1111|Model11111,Model22222,Model33333,Model44444,Model5 5555
SKU9999|ModelHHHHH,ModelJJJJJ,ModelMMMMM

How do I do this?

View 1 Replies View Related

Active Records Between Two Dates

Mar 20, 2005

I am working on a project where I need to monitor employees who are on vacation. I would like to run a report that would show employees who are currently on vacation, and those that have already returned. This is the information that I am looking to get from the report.

Search Dates: Entered criteria thru qry, msg windows asks for "start date" and "end date".
1/01/05 - 1/31/05

tblName
John Smith

tblEmployee#
1234

tblDate left (on Vacation)
12/25/04

tblReturn Date
1/25/05

Days on Vacation
31

tblName
Tina Roberts

tblEmployee#
1243

tblDate left (on Vacation)
1/25/05

tblReturn Date (If the employee has not returned it would give the "end date" and calculate the days on vacation)
1/31/05

Days on Vacation
6

This may seem simple but I just can't get the qry to show dates beyond the "start date" and "end date". Only those records that start within the two dates.

Any help wpuld be greatly appreciated.

View 6 Replies View Related







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