Queries :: Select Query Multiplies Records?

Feb 5, 2014

I'm having a bit of a situation with a select query that I set up.

I have two tables, both with a list of serial ID's.

One is table field is formatted like this:

"B0340 13 453423 X"
The other is formatted like this:
"=B03401345342300"

I wanted a select query that could show me the records in a universal serial like this:

"034013453423"

This leaves out the "spaces", the "B" and the " X". (Couldn't find a way to make Access generate a new field with the serial ID correctly without a query).

So I used the "Mid" expression in a select query and it worked, it showed me the first table in the correct format.I wrote the same "Mid" expression for the other table and it worked too.But, when I ask for the results for both tables in the same query, it shows me much more records than I have(all duplicates). I figured out that when in table one I have 20 records, in table two I have 5 then the query shows 120 results (20 x 5).

This is the code in SQL view:

Code:
SELECT MainDatabase.[Transfusie Eenheid + Specification], (Mid([MainDatabase].[Transfusie Eenheid + Specification], 2, 4) & [MainDatabase].[Transfusie Eenheid + Specification], 7, 2) & [MainDatabase].[Transfusie Eenheid + Specification], 10, 6)) AS [BloedeenheidID MD], ScannedForms.BloedEenheidID, Mid[ScannedForms].[BloedeenheidID], 3, 12) AS [BloedEenheidID SF]
FROM MainDatabase, ScannedForms;

View Replies


ADVERTISEMENT

Queries :: Get A Query To Select All Records?

May 3, 2014

I'm having a problem get a query to select all of the records it should be.

When I filter the source table (200_STANDARDIZED NRGL) to show the data I want to see (PC2 = 6000; GAAP = 02; CGL = 0950, 2735, 2736, 3500 and 3501; STD VENDOR NAME = blanks), I get 33 records.

NOTE: Had to take the PC2 records that were not '6000' out of the dB I've attached in order to be able to send dB bu the PC2 filter is needed in the complete dB.

When I create a select query to the do the same thing, I get either:3 records (when I set STD VEND NAME to Like '') or 30 records (when I set STD VEND NAME to NOT Like '*' ) I've attached the dB - Query 1 is the subject of bullet 1 above and Query 2 is the subject of bullet 2 above.

BTW, the three records that show up in Query 1 are the same records missing from Query 2.

View 3 Replies View Related

Queries :: Update Query On Select Records

Apr 4, 2013

I have a Sales Table with below fields, i might have not set it up in the best way possible.

Consumer, Consumer_ID, SaleDate,Prod_Sl#,Prod_Type,Sale Amount

1. I need to update the sales price for each item sold based on category of Product Type, as we are tracking the product with Serial Number.

For an instance if 2 items of Category1 with Prod_Sl# as Sl1 and Sl2 and
2 items of Category 2 with Prod_Sl# as Sl3 and Sl4 are sold.

I need to update the sales price amount for these.

2. I want to accomplish this using a query.

View 1 Replies View Related

Queries :: Select Query Losing Records?

Sep 19, 2013

I have a Union query as follows;

SELECT ALL *
FROM 1st_Lives
UNION SELECT ALL *
FROM 2nd_Lives;

1st Lives has 465,414 records and 2nd Lives has 151,852 records.

When I run the query I only get 604,976 records instead of 617,266 (I basically just want to add the two data items together).

View 1 Replies View Related

Queries :: Use A Query To Select Specific Records From Table

Dec 14, 2013

While I am not new to Access, I am not well versed in its abilities as far as combo boxes go. What I have is a Form where a combo box allows you to pick from a table records 'record ID #' in order to fill in the data of that record to the rest of the form.What I want to do is use a query to select specific records from this table and allow the combo box to show only these 'selected Record IDs' for user selection.

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 :: Select Query - Count How Many Records Not In Correct Format

May 7, 2013

So I have a table with around 20,000 records and there is a field which holds a phone number for each individual within the organization, I want to run a select query that counts how many are not in the correct format

The format is 10 digits and it must start with a 0

Using Access 2010

View 2 Replies View Related

Queries :: Select Query To Pull Records Based On Multiple Strings Entered By A User?

May 1, 2013

Is it possible to run a basic select query to pull records based on multiple strings entered by a user?

I have a query with field criteria - Like '*' & [Type In MMDBID:-] & '*'

This allows the user to input one MMDBID and the records are retrieved from the db.

I can also use the OR statement in the same field criteria "AB123" OR "BC123", and all records based on those values are pulled back.

But I cannot get the user to input multiple values and I tried amending the SQL string based on the OR criteria above

SQL statement (Like) is below :

SELECT tblFund.MMDBID, tblFund.[Investment Name], tblCodesLive.[IOE Code], tblCodesLive.[Uptix Code], tblFund.[Red Payment Deadline]
FROM (tblFund INNER JOIN tblCodesLive ON tblFund.MMDBID = tblCodesLive.MMDBID) INNER JOIN tblContact ON (tblFund.MMDBID = tblContact.MMDBID) AND (tblCodesLive.MMDBID = tblContact.MMDBID)
WHERE (((tblFund.MMDBID) Like '*' & [Type In MMDBID:-] & '*') AND ((tblFund.Editing)=False) AND ((tblFund.Closed_Fund)=False));

View 10 Replies View Related

Queries :: Select Query To Gather Results Of Other Select Queries

May 11, 2014

I'm fairly new to Access. 's various select queries containing useful and useless results. I want to create a select query that will pick out all the useful figures into a 1 row table that can then be pasted into Excel.

e.g Existing Select Query 1 returns 1 row showing Average Age, Average Price, Total rainfall
Existing Select Query 2 returns 1 row showing Average Weight, Average Salary, Total snowfall
Existing Select Query 3 returns *2* rows: It returns Distance from London, Hours daylight and population for Town A and Town B

I want a select query that returns 1 row showing (6 items):

Total rainfall, Total snowfall, Town A Distance from London, Town A Population, Town B Distance from London, Town B Population.

I've been able to handle getting Total rainfall and Total snowfall. But I cant figure out how to get Town A Distance from London, Town A Population, Town B Distance from London, Town B Population to appear in the same row of the same query results as Total rainfall, Total snowfall.

View 3 Replies View Related

Getting Query Criteria To Select All Records Or Specific Records In Query Design Section?

Jun 16, 2014

How can I get a Query Criteria To Select All Records or specific records in query design section.

I have a table that shows many departments with credit card transactions. I like to run a query to see specific department, or have an option to see all the departments when the query is run.

View 2 Replies View Related

Queries :: SELECT TOP 3 Returning More Records

Mar 24, 2015

My statement below is current returning 4 records. Two of the records have the same GBPAmount value.

RequestID is the Primary Key

Code:
SELECT TOP 3 RequestID, GBPAmount, Currency, RequestDate
FROM PayRequest
WHERE (((Currency)="CAD Canadian Dollar") AND ((RequestDate)>#11/16/2014#))
ORDER BY GBPAmount;

Code:
RequestID GBPAmount Currency RequestDate
10207 8.17 CAD Canadian Dollar 03/02/2015
9874 33.82 CAD Canadian Dollar 20/01/2015
11327 109.58 CAD Canadian Dollar 23/02/2015
10495 109.58 CAD Canadian Dollar 05/02/2015

View 3 Replies View Related

Queries :: Select Records With Minimum Value

Mar 12, 2015

I would like to select records based on Minimum values of specific vendor.

Example:

MasterItemID Price PriceDate VendorID
1 2 2/5/14 30
1 3 2/5/14 31
1 7 2/5/14 32
2 3 2/5/14 31
2 2 2/5/14 32

So wants the all columns where price is minimum

Example: output required

MasterItemID Price PriceDate VendorID
1 2 2/5/14 30
2 2 2/5/14 32

View 6 Replies View Related

Queries :: How To Select Records When Date Is Less Than 30 Days Apart

Mar 10, 2014

I have a large database filled with customer records. Some customers come one time. Other customers come 50 times at year. I want to find all customers that have records that are less than 30 days apart so I can ultimately see the types of products they buy. How do I write the query?

I attached a picture of a sample database. The 30 day (+/-) field doesn't exist but I would like the query results to build it.

View 11 Replies View Related

Queries :: Get Average Of Select Group Of Records?

Sep 26, 2013

I am trying to get the average of a select group of records within a query. It appears the davg function should give me what I need, however my query returns no results. Here is a sample of my data.

Item Cost Basis Group Cost
1HF20812 1HF208 6.17
1HF20816 1HF208 8.63
1HF20820 1HF208 9.44

Here is the davg string I am trying to use.

Group: davg("Cost","Cost Basis Group")

View 2 Replies View Related

Queries :: Select Random Records From Unrelated Tables

Aug 9, 2014

I am fairly new to Access 2013 but am trying to create a query that will select random records from three totally unrelated tables and display the results together as if one table -- think video slot machine wheels. Each table has two fields - ID which is the primary key and NAME. The data in the tables are names of states, names of colors, and types of animals. Each table has a different number of records. My end result is a table that selects X number of random records from each table and displays them side by side like this:

Desired Result:
Animal Color State
cat red Ohio
dog blue Texas
fox green Iowa

I have been able to create three individual queries that will pull X number of random records by using:

SELECT TOP 10 Animals.[ID], Animals.[Name] FROM Animals ORDER BY Rnd(-(100000*[ID])*Time());
SELECT TOP 10 Colors.[ID], Colors.[Name] FROM Colors ORDER BY Rnd(-(100000*[ID])*Time());
SELECT TOP 10 States.[ID], States.[LongName] FROM States ORDER BY Rnd(-(100000*[ID])*Time());

Using the three queries above I get three separate lists. how to make one query that will randomly pull from all three tables and make the display above?

View 14 Replies View Related

Queries :: Select Records By Comparing Time Stamps In 1 Field

Jun 26, 2014

I can not solve this problem, my Access knoledge is mediocre.

I have the following table from imported data:

RecNr IPaddres DateandTime
1 178.00.000.01 20-11-2013 21:47:21
2 178.00.000.01 20-11-2013 21:47:59
3 178.00.000.01 20-11-2013 21:48:35
4 178.00.000.01 22-11-2013 20:44:59
5 178.00.000.02 22-12-2013 19:47:59
6 178.00.000.02 22-12-2013 20:47:59
7 178.00.000.03 01-02-2014 12:47:59
8 178.00.000.03 01-02-2014 12:48:30
9 178.00.000.03 01-03-2014 11:47:59
etc

I want to make a query that results in displaying records that have the same IP-address where the difference in the date/time stamp is within 1 minute. When the date/time stamp is > 1 minute the record can be deleted from the table.

View 6 Replies View Related

Queries :: SELECT DISTINCT Not Removing Duplicate Records In Staging Table

Jan 29, 2015

I have a database with an import process which normalises incoming data and appends to various tables. No issues with that. I also have a function within that process which counts the number of new entries for a summary popup when the process has completed.This works by querying the staging table, prior to the append, into a recordset and using the .RecordCount to increment the count (multiple files can be imported at once so this effectively provides a running count, per file, to give a total for the whole import)

I thought it was working fine but this morning I noticed that the count which appeared on the popup was 1 greater than the number of actual new records. I checked the source files and noticed that, for whatever reason, there was a duplicate entry in there. So I presume that's why the count was out by 1.

There's no integrity issue in the main tables as the composite primary keys ensure that duplication shouldn't be a problem. Indeed, the record in question, duplicated in the source, appears only once in the main table post-import. So not too worried about that.

However, I need the count in the popup to be accurate (it tells the users how many new entries require further investugation). And what's puzzling me is that I use DISTINCT in the query, which I would have thought should eliminate any potential dupes in the recordset and thus provide the correct count. It seems it doesn't?

Code:
Public lngNewBalancesTBI As Long ' Defined in a separate module...
-------
Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String

[code]....

Why the dupe, which is still present in the staging table, also makes it over to the recordset, even though I'm using DISTINCT?

View 14 Replies View Related

Queries :: SELECT Records From A Table Based On IN Clause And Sort Them In Order

Jan 4, 2014

WinXPPro Sp3
Access 2007

After some research I thought I had found a neat way to SELECT records from a table based on an 'IN' clause and sort them in the same order as the values for the 'IN' clause... i.e.

Code:
SELECT Unique_No, Table_Name, List_Order FROM My_Table
WHERE Table_Name = 'Titles'
AND List_Order IN (3,1,15,4,5,12,7,2)
ORDER BY INSTR('3,1,15,4,5,12,7,2', List_Order)

Unfortunately, this returns list_order 5 just after 15 and list_order 2 just after 12, thus

List_Order
3
1
15
5
4
12
2
7

View 3 Replies View Related

Returning Select Records In Query

Mar 30, 2006

Hello, I am sure this is quite simple, however I cannot figure it out. I have a query that shows tblPartNumber and tblAverage. The average is calculated in the query by taking the total minutes to assemble the parts, divided by the number of parts completed. What I am trying to do is run a query that will show me the most efficient (lowest average), time for each Partnumber. Ideally the query would show me something like this;


Part # Average
1234 .72
1234 .86
1234 .94
etc...

I searched on here and it seemed like the Top 10 is used, but in my application that ommits all of the other partnumbers because it only shows ten of the records for the first partnumber. I only want to see the five most efficient averages. Any help is greatly appreciated.

Thanks, Tim

View 3 Replies View Related

Query To Select The Duplicated Records.

Jun 23, 2006

Hello,

I want to make a query that retrieves me all the duplicated records from a table. Itīs possible?

Thankx

View 1 Replies View Related

Select Query Showing Too Many Records

May 27, 2007

I have two tables, bad design, not my choice of the way it's set up.

Table a has Fields 1-2, dups allowed in all fields. No pk was originally assigned.
Table b also has the same fields 1-6, but also has field 6.

Table a has all of the records in question, table b only has some of the records from table a but does not have any records that are not in a.

Something like this.
Table a

Field1 Field 2 Field 3 Field 4 Field 5
John Shirt blue denim button
Mark pants green straight
John Shirt blue silk button


Table b

Field1 Field 2 Field 3 Field 4 Field 5 Field6
John Shirt blue denim button new
Mark pants green straight used


If I query the two tables, a left join to b, then I get the correct number of total records. If I select any records from b, then the total records goes higher than there are, even for the two combined, listing the same record multiple time.

Any suggestions are appreciated. I am a blood bank lab person, not an IT person, or DBA, so simple responses are greatly appreciated.

View 6 Replies View Related

Select Only Records For Specific ID Query

Jul 31, 2007

This is killing me,

I have a form with a unique ID, I have a query that pulls all data regardless of the ID on the form.

How can I get the Query to pull only the data for the ID that is currently in view on the form?

Please help..

Thanks,

Fen How

View 2 Replies View Related

Query To Select 20 Random Records

Aug 9, 2007

As part of my job, each month I have to select 20 problem report resolutions and grade them on quality. Typically we have about 100 problem report resolutions per month. Is there a way I can use a query to return a random selection of 20?

Thanks,
Jim

View 1 Replies View Related

Select 20 Random Records In Query

Mar 12, 2008

I have to review 20 reports each month for quality check. I have a query that lists the reports completed within the past 30 days. Is there a way to filter this query to show only 20 random records?

If there is no way to do this, can you suggest some way of doing this so that it's impartial? For example I don't want to select the first 20 of the month because everyone will catch on and wait late in the month to post their report. Normally about 70 reports are completed in a month.

Thanks,
Jim

View 3 Replies View Related

Query Criteria With Option To Select All Records

Aug 22, 2007

I am developing an Event Management DB for business training courses. I have an attendees table with a link to CompanyNames. I wish to be able to produce an attendees report based on the CompanyName ie all attendees from the selected company. I have done this by using a dropdown of companynames on a Criteria selection form. This works well.
What I would also like to do is print the same list without the companyName criteria. I am aware I could make another query but was hoping that maybe there is a way of setting up the criteria in the companyName field so that it could accept either a company name or ALL company names.

Hope someone can help.

Thanks

Peter

View 2 Replies View Related

Queries :: Select Query From Another Mdb?

Mar 20, 2013

are you able to specify the location of another database that you want to select data from?

For example: I want to do something like this:

SELECT [field1], [field2] from C:DesktopFolderMyOtherDatabase.mdbTableName

View 4 Replies View Related







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