Multiple Joins In Multiple Table Search Query

Sep 21, 2004

I am trying to create a simple Search form in Access where a user can select a desired record and query multiple tables using the inputs.

I would like them to be able to query Retailers, Distributors and Products.

The 6 tables are linked as follows:
Although some of these tables are not included in the query, they are required to ensure relationships.

Retailers -- Uses (RetailerID,DistributorID) -- Distributors
Retailers -- Orders (RetailerID,ProductID) -- Products

All retailers have at least one distributor BUT a retailer may or may not have ordered any products.

I have created my form but the query linked to the form is having some trouble. It is only selecting those records that have ordered products. For example, if I query a retailer name only and it does not have any ordered products, it will not display. Is there a problem with the table joins? The SQL for the query is displayed here:

Code:

View Replies


ADVERTISEMENT

Help Please With Multiple Outer Joins To Return All Records From Main Table

Jun 5, 2007

I have this query in design view and in an asp page and it works fine:

SELECT dbo_feedback.*, dbo_origin.originName, dbo_product.prodname, dbo_category.catName FROM dbo_product INNER JOIN (dbo_origin INNER JOIN ((dbo_feedback INNER JOIN (dbo_category INNER JOIN links_cat ON dbo_category.catID = links_cat.CatID) ON dbo_feedback.id = links_cat.FeedbackID) INNER JOIN links_product ON dbo_feedback.id = links_product.FeedbackID) ON dbo_origin.originID = dbo_feedback.origin) ON dbo_product.prodID = links_product.ProductID;

BUT, I want to return all feedback entries, even if they have no matching Product or Category. :confused: When I change the inner joins to outer joins I get a syntax error in the browser window. I changed the join type in the relationship diagram in Access and tried to recreate this in query designer, but Access says the statement cannot be executed because of ambiguous outer joins.

FYI, one feedback can have many products, many categories, and only one origin. I have the joins correct and enforced.

Please help, thanks!!!

View 1 Replies View Related

Query With Multiple Outer Joins Gives Wrong Result

Dec 15, 2007

Hello,

My query references 2 related tables: one for persons (PERS) and one for telephone/fax numbers and email addresses (CONT, for Contacts).
The relevant fields are:

PERS
pers_id (long) ---> primary key
pers_forename (text)
pers_surname (text)

CONT
cont_id (long) ---> primary key
pers_id (long) ---> foreign key
come_id (long) ---> foreign key
cont_number (text)

The foreign key come_id refers to a table for contact methods (COME), either "Phone (Home)", "Phone (Work)", "Mobile", "Fax" or "Email".

Now i want to list all persons with their home phone number and email address, also if they don't have one. It seems to be impossible to get it ...
I will explain what happens. Lets start simple: first list all persons with their home phone number (come_id = 1):
SELECT PERS.pers_forename, PERS.pers_surname, CONT.cont_number AS Phone
FROM PERS LEFT JOIN CONT ON PERS.pers_id = CONT.pers_id
WHERE (((IIf(IsNull([come_id]),1,[come_id]))=1));
This works fine. The IIf expression is necessary since we are dealing with an outer join: not all persons have a home phone number. If we would simply put "WHERE come_id = 1" then the query produces only the persons that have a home phone number.

But now i also want to see the email address (come_id = 5):
SELECT PERS.pers_forename, PERS.pers_surname,
CONT.cont_number AS Phone, CONT_1.cont_number AS Email
FROM CONT AS CONT_1 RIGHT JOIN
(PERS LEFT JOIN CONT ON PERS.pers_id = CONT.pers_id)
ON CONT_1.pers_id = PERS.pers_id
WHERE (((IIf(IsNull([cont].[come_id]),1,[cont].[come_id]))=1)
AND ((IIf(IsNull([cont_1].[come_id]),5,[cont_1].[come_id]))=5));
It seems perfectly logical: i added a second alias CONT_1 for the email address. Since this is also optional we have a second outer join, and the WHERE condition should also use an IIf expression.
The result is not correct though: the resulting recordset shows only the persons that have both a home phone number and an email addres or neither!
I have a lot of experience with SQL and queries, but i know i am not infallible. Nevertheless i am quite convinced that i should get all the persons: those that have a home phone number or an email address, or both or neither ...
I hope that someone of you can explain this.

View 3 Replies View Related

Multiple Joins

Jul 24, 2007

Hello,
I have the following code for a multiple join:

INSERT INTO [AppendAllFields]SELECT [TreatyList].[Treaty] AS [Treaty],[MLAC 42 Treaty Xref ER].[tai treaty] AS [TreatyType],[txn 01/04].[Policy_Number]
(and more other fields from [txn 01/04] table)
FROM [txn 01/04] INNER JOIN [MLAC 42 Treaty Xref ER] ON TRIM([txn 01/04].[Policy_Number]) = TRIM([MLAC 42 Treaty Xref ER].[Polnum])
INNER JOIN [TreatyList] ON TRIM([MLAC 42 Treaty Xref ER].[tai treaty]) = TRIM([TreatyList].[TreatyNo]);

Basically, the txn 01/04 table has a corresponding Polnum field in the MLAC 42 table, and MLAC 42 table has a tai treaty field, which corresponds to TreatyNo in TreatyList table.

However, when I tried to run this, I got an Syntax error.

Could anyone please help?

Thanks!

View 4 Replies View Related

Multiple Inner Joins Question

May 3, 2006

I am trying to set up a file compare process. I load the two files into two "matching" tables (there is a key field). I have a series of queries which find any differences in the various fields and displays them. My problem is that one field (Field4 - a tran code) is coded 1,2,3 in one file and A,B,C in the other. I have set up a third translation table with two columns, each row showing the matching codes (1/A, 2/B, 3/C, etc). I want to find corresponding rows in FILE1 and FILE2 (matched on KEY) where tran codes (Field4) do not match (ie a "1" in File1 but NOT a "A" in FILE2).

I have not been able to get the two inner joins to work. Can some one help.

This is my last attempt:


FILE1: KEY-Field1-Field2-Field3-Field4
FILE2: KEY-Field1-Field2-Field3-Field4
(Field4 is the code that needs to be translated)

FILE3/numeric/alphabetic
1 A
2 B
3 C
4 D


SELECT FILE1.KEY,FILE1.Field4, FILE2.Field4
FROM
FILE1 INNER JOIN FILE2 ON FILE1.key = FILE2.key
INNER JOIN [FILE3] ON (FILE1.Field4 = FILE3.alphabetic)
WHERE FILE2.Field4 <> FILE3.numeric.

Hope this makes sense.

Mac

View 3 Replies View Related

Multiple Fields Of Multiple Tables To One Table Query Or Report

Apr 12, 2013

I have 10 tables, 30+ fields on each table (every table has the same 'account number' field). I only need from 5 - 20 fields from each table. How do I get the certain fields from each table and put them in a table, query or report?

View 1 Replies View Related

Multiple Left Joins From Same Column

Sep 8, 2011

I have a table (Table A) that includes every number that's been dialed in our call center. I have another table (Table B) that has account numbers and three different phone fields for each account.

What I initially tried was to left join the Dialed Number column from Table A to all three phone number columns in Table B. This produces no results. If I only join Dialed Number to Phone Number 1 (for example), I get results, however, if the agent dialed one of the other two numbers, it's not going to show up.

View 1 Replies View Related

Read/Write Queries, Multiple Joins...

Jun 30, 2005

Okay, take three tables.

AreaTable
AreaID
AreaName
Percent

GangTable
GangID
Area_ID
Speed

MasterTable
MasterID
Station
Description
Area_ID

The Relationships

AreaTable.AreaID 1---------> (inf) GangTable.Area_ID
AreaTable.AreaID 1---------> (inf) MasterTable.Area_ID


Initially the query below used Inner Joins, however that limits my list, when i want to see ALL elements from the MasterTable no matter what, thus my inner joins became left and right joins as follows.

Simple Query: Query1

SELECT MasterTable.Station, MasterStable.Description, MasterTable.Area, AreaTable.Percent, GangTable.GangID, GangTable.Speed
FROM (AreaTable RIGHT JOIN MasterTable ON AreaTable.AreaID = MasterTable.Area_ID) LEFT JOIN GangTable ON AreaTable.AreaID = GangTable.Area_ID;


This should simply display All Records in MasterTable, (Multiple Times if Necessary) listing all the elements of AreaTable that are Linked to the MasterTable, and all elements from GangTable that are linked to AreaTable. It does this, and displays them nicely. But I can't edit the fields. I get the result:

1 | Station One | Area 1 | 45% | 204 | 1000
1 | Station One | Area 1 | 45% | 304 | 500
1 | Station One | Area 1 | 45% | 404 | 750
2 | Station Two | Area 1 | 45% | 204 | 1000
2 | Station Two | Area 1 | 45% | 304 | 500
2 | Station Two | Area 1 | 45% | 404 | 750
3 | Station Three | Area 2 | 75% | 254 | 800
3 | Station Three | Area 2 | 75% | 354 | 600
3 | Station Three | Area 2 | 75% | 454 | 700


So you can see that Area 1 has multiple Gangs (204,304,404) and Multiple Stations (1,2). If you do a simple set up like this, you'll find that you can't change the Description field (Rename "Station One" to "Hello World"). It just doesn't work, no matter which way I've tried, I can't seem to make a Query that presents all the information from MasterTable and All the Information IN AreaTable and All the Information in GangTable which will allow me to also edit the fields.

Any Help would be most appreciative, I'm tearing my hair out on this one.
Thanks,
Jaeden "Sifo Dyas" al'Raec Ruiner

ps - It just seems that with Junction Tables and all the many to many relationship designs I have tried, you'd be able to change the non-related fields. I understand that you can't change the "ID" fields, but the others should be editable.

View 2 Replies View Related

Search Multiple Text Fields In A Table From A Form

Aug 8, 2006

Please bare with me as I am an Absolute Access VB code novice . I have a Form in my Access DB and I found the Following code on this site and placed it behind my search button :

Private Sub SearchButton_Click()
DoCmd.OpenReport "All users", acViewPreview, , "[AUP].[First Name] = '" & Me.[Text34] & "'"

End Sub

The Search works great but only searches on the 1 Field "First Name" . How would I expand the VB code to include another 2 fields within my table . ( the other 2 fields I want to serach appear on the Form ) .

View 4 Replies View Related

Forms :: Search From Multiple Table At Same Time In A Form

Jun 26, 2013

I am attempting to create a search form where a user can search by either employee name or company name. I have 5 tables to use. Is there a simple way of creating a search method for this? I would like to be able to have the user type in a name and click a button that says search with any records matching the search come up. However, I could definitely use a method where they type it in a box and it finds it as the person types.

How to search from all five tables at the same time.

View 3 Replies View Related

Multiple Search Criteria For 1 Query

Jun 29, 2006

Hi all
I have a query linked to a report that prints a worksheet specific to a individual work item. This report/query picks up the Work_ID value on a form. I have 2 other forms displaying the same work with different amounts of detail. Rather than create a new report/query to run from each form, I am trying to use the one query/report from each form.
The problem is that I cannot get Access to recognise the Work_ID value from the other forms. I have tried the following:

In the Work_ID criteria field building an SQL statement as below
[Forms]![frmVCRUpdate]![Work_ID] Or [Forms]![frmVCRShort]![Work_ID] Or [Forms]![frmVCRLong]![Work_ID] - This does not work, it keeps asking for the frmVCRUpdate Work_ID value when I try to run the query from the other forms
Adding 2 extra Work_ID Values to the query and on the 2nd and 3rd criteria lines specifying that it look for the Work_ID value from the other forms but I get the error above.

Any suggestions on how I can make this work would be appreciated, I'm not sure what else to do.
Craig

View 2 Replies View Related

Multiple User Specified Parameters For Search Query?

Mar 30, 2006

Hello

I have created a database for my department to log all of our jobs to keep track of them and I want to create a simple search for them but I am having difficulties.

I am familiar with creating queries to search tables for matching records, but is it possible to get search criteria from the user (ideally from a search form they fill in) to form the query?

For example, I would like the user to be able to query the jobs by month and/or business area and/or supplier...is this possible?:confused:

Any help gratefully received!!!
:)

View 2 Replies View Related

Queries :: Search Across Multiple Tables With One Query

Apr 18, 2013

Is it at all possible to search across multiple tables with one query. I have a database with about 15 tables and my users would like to be able to search for text across all the fields in all the tables. I have a simple find record command on each table, but in case they are not sure which table to search i would like to offer a search function which in theory searches the whole database.

I have 15 tables (eg witnesses/policies/activities etc), each with different fields (eg name, address/ policy decision, policy reason/ activity undertaken, activity person etc etc) . In total i would like to be able to search about 50 fields. All i need returned from the search is the record ID from the relevant table, or anything to simply identify the record & relevant table. And then they could go to the correct place to look the record up.

I have been looking for an answer for a while. I have seen queries where you enter the parameters against each field going down a row each time for criteria being "OR" each time, but there are a limited number of rows on a query design so i run out of rows.

View 7 Replies View Related

Get A Multiple Keyword Search Query Working

Mar 4, 2013

I am trying to get a multiple keyword search query working.... the single search is working however when i use the Multiple Keyword search the data sheet does pop up but no matter what i put in i just get a blank table and under ID it says "NEW"

The Keywords Column has a bunch of keywords separated by commas on each row. Sometimes there will be the same keywords on different rows under the keyword column... and i want it to return any rows that have 1 or more of the keywords in it or if it is null just to return them all....... this is the statement I am trying...

SELECT Sea.ID, Sea.Category, Sea.Title, Sea.Author, Sea.Organisation, Sea.Date, Sea.Keywords, Sea.Reference
FROM Sea
WHERE (((InStr([Keywords separated by commas,Blank=All],[Keywords]))>0 Or (InStr([Keywords separated by commas,Blank=All],[Keywords])) Is Null));

View 3 Replies View Related

Forms :: Form To Search For Multiple Words And Run Query?

Dec 16, 2013

I am having some difficulty putting togather a small database (attached).

Basically I want to be able to search for mutiple words and get the results

There are 3 main columns in the main table

1) Shop
2) Part Number
3) Part Type

Problem 1:I have created a lookup table (with check boxes) for ComboBoxes in a form but I do not know how to connect it so that when I click on the comobo box it gives me the all different (Shop numbers/part number/Part types) to select from.

Problem 2:Once I have made my selection I want to search and run query to show me the results. I know that once multiple items are selected in a combo box they are separated by commas/space, so the search must take that in account.

Other nice to have
1) If Shop 1 is selected then only the parts which were sold from shop 1 to appear in the Part number Box & visavera & same goes for Part type.

2) Ability to do a wildcard search so if I Enter "A" in part number I can see all the resealts

View 12 Replies View Related

Queries :: Search With Multiple Fields Result From Query

Dec 26, 2013

I want to make a form which will allow me to get data from a query and search using 3 fields parallel.

Attached the database in 2010 format.

Password of the db is "nolimit".

The query PTM & Equipment should be bound with the form and

If I enter month, PTM and equipment need rest 2 fields displayed.

Like choosing the above 3 fields from the drop down , the next 2 text box should display the rest two fields.

View 3 Replies View Related

Forms :: Search Multiple Fields In Table And Open Matching Records For Editing

Dec 10, 2014

Create form to search multiple fields in table

Return records that match search

Open the record that you want in Form View for editing

View 1 Replies View Related

Query Linked To Form With Textbox To Search Multiple Fields

May 22, 2006

Right what im after sounds complicated but its quite simple.

I have a client database, in this database each client has 3 skill fields, i also have a form with a listbox and an unbound textboxes that are linked to the query so when the textbox is typed in the listbox updates.

Now ive sorted out the problem of not all fields showing it some of them are blank now the problem is.

When input text into one of the boxes the listupdates, now if theres text in two boxes. and theres data in one of each that matches it will show neither, because the query is looking for data that matches in both fields, now i need partial matches so it will give results of data in both fields.

not understanding fully what i mean?

i have zipped my db, if you open the db then open the form 'MainListRecTrades2nd' and fill in data in both primary and secondary trades that matches from the list you will see.

http://awilderbeast.com/CWSystem.zip

The solution i was thinking of would to have 1 textbox that searches all the fields and displays data from any of the fields in the list

Thanks for any help

View 7 Replies View Related

Queries :: Search Query Using Multiple Combo And Text Boxes

Aug 13, 2013

I have a table with all information on it, that is input via various forms, I then have different queries pulling information from all information to run reports off. These all work fine, my problem is my 'Search Form' - below

I have created a query that finds information from 'all information' using

Like "*" & [Forms]![SearchAll F]![txtDateRasied] & "*"

This is working on all text boxes, It only half works on the combo box's when I use

Like "*" & [Forms]![SearchAll F]![combofailureanalysis] & "*"

If a selection is made in the combo box the query brings the correct results, however, if all the fields are left blank it should bring up every record, but it doesn't do this. I am certain it is the combo box's that are causing this anomoly as when I remove the combo box criteria it works perfectly again.

View 11 Replies View Related

General :: Export Access Table To Multiple Excel Workbooks With Multiple Tabs

Dec 13, 2012

I am using Access 2010 and Excel 2010. I need to have VB script to export the access table 502 records by 38 fields into Multiple Excel workbooks each having multiple tabs. In the Access table each record has two fields: Div and Tab that will be used to name each workbook and each tab (sheet). There are 6 unique "Div"'s to name the 6 workbooks and there are several "Tab" names for each Div (workbook).

Note: These 6 workbooks with multiple tabs were originally imported into Access from one common folder on my desktop by this routine:

Option Compare Database
Option Explicit
Private Sub Command1_Click()
Dim blnHasFieldNames As Boolean, blnEXCEL As Boolean, blnReadOnly As Boolean
Dim lngCount As Long

[Code] .....

View 7 Replies View Related

Export Access Table To Multiple Excel Workbooks With Multiple Tabs (sheets)?

Dec 13, 2012

I am using Access 2010 and Excel 2010. I need to have VB script to export the access table 502 records by 38 fields into Multiple Excel workbooks each having multiple tabs. In the Access table each record has two fields: Div and Tab that will be used to name each workbook and each tab (sheet). There are 6 unique "Div"'s to name the 6 workbooks and there are several "Tab" names for each Div (workbook).

Excel workbooks would take names from the "Div" field and the tab names would come from the "Tab" field in the Access table. First need to find workbook name (Div - Field) then the look for each sheet name (Tab - Field) to create 1st Excel workbook with all the sheets (Tab) and repeat the process. I think you need to approach of read the Access table one record at a time keying on the "Div" and "Tab" fields in creating each Excel workbook with the associated multiple tabs (sheets) that are written to a common folder.

Note: These 6 workbooks with multiple tabs were originally imported into Access from one common folder on my desktop by this routine.

Option Compare Database
Option Explicit
Private Sub Command1_Click()
Dim blnHasFieldNames As Boolean, blnEXCEL As Boolean, blnReadOnly As Boolean
Dim lngCount As Long
Dim objExcel As Object, objWorkbook As Object
Dim colWorksheets As Collection

[code]....

View 12 Replies View Related

IMPORTING MULTIPLE FIELDS FROM MULTIPLE DATA SETS INTO A TABLE

Nov 16, 2006

I HAVE A DATASETS cSV TEXT FORMAT WHICH HAS A SELECTION OF FIELDS THAT NEED TO BE IMPORTED INTO A TABLE. USING THE ADVANCED IMPORT FACILLITY I HAVE BEEN UNABLE TO IMPORT THE DATA PLEASE HELP AS THIS IS FOR MY A-LEVEL STUDENTS.


THE FIELDS REQUIRED IN THE SESSION TABLE ARE,
Booking ID, Customer ID, Date Booking Made, Pickup Point, Payment Made

The CSV data set attached

tHANK YOU

SIMON

View 2 Replies View Related

Multiple Table Query

Nov 15, 2007

Hi all,

Another month, a new database, more questions... a quick thankyou to all those who helped with my last database, much appreciated!


I am trying to set up a query run from 12 tables, each table is supposed to be the same but we have had a number of people changing things when they shouldnt have been. Each table is a month of posts in our employee headcount, each post has a ID Key which shuold stay the same throughout, some of these IDs have been deleted when they shouldnt have been, some more have been added when, again, they shouldnt have been. Each post ID has a set FTE number (dictates the hours they do a week), some of these have changed, again when they shuoldnt have, some have changed when they shuold have and we have a record of these ones.

I need to be able to check which post IDs have been deleted, what month (or table) they were first deleted from. What post IDs have been added and what month/table these were first added. I guess i use the first table as the reference point and also that maybe layered queries (compare tables 1st month/second month and then do a query on those results against 3rd month and so forth but not sure how this would pick up changes from the first month...) but not sure quite how to do this and whether this is the right way to do things. The next thing to do will be to check the FTEs but will wait until i sort this query out first.

thanks in advance

Shapman

View 2 Replies View Related

Multiple Table Query

Dec 17, 2007

I am pretty bad at trying to describe things but let me give this a shot. I have inheareted a BEAST of a DB to try and maintain; not to mention add all sorts of new requests I get handed from mgmt.

I need build a query that takes information from a table of monthly quota data, pull out how many of each we have repaired from a work table, and pull description information from a third table. All this needs to be sorted by month.

Here's sort of what I am trying to get out of the query:

Item / Jan'08Quota / Jan'08Repaired / Feb'08Quota / Feb'08Repaired

I would think this would be easy; but I just can't seem to get it to work. First off; just pulling out repairs by date I cannot get the wildcards to work. I have to run the query with the date being >=#01 Dec 07#; I cannot get it to pull Jan/Feb/Mar/etc...
Secondly; when I try to take the quota data w/repair data w/descript data I get results that just do not make any sense. Not sure how/where that is all messing up.

Anyhow; I don't know what else I should post with this that could give anyone an idea on how to make things work. If you have a thought, please let me know :) If you need information to help understand what I'm trying to ask, just ask away and I'll do my best to answer.

Thanks
AC

View 3 Replies View Related

Multiple Table Query

Jun 1, 2006

I know this is a rather elementary Access function, but i cannot get it going: Whenever I run a query combining fields from two tables, the records come up empty. What could i have done wrong? the tables are in same db., with common fields. One thing is, when I try in the relationship window to enforce referential integrity I get an error message which reads 'no unique index.' I am baffled because the primary key in the parent table related to the same field in the child table.

View 4 Replies View Related

Multiple Table Query

Jun 10, 2006

I've read about doing a multiple table query and I tried it but I don't get any results. I have three tables, each with a field named location. Basically, I want to treat it as if they were all just one table and pull distinct values from them. I'd post the SQL I tried but I think I have it so out of whack that it wouldn't even help.

Thanks!

View 7 Replies View Related







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