Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / August 2006

Tip: Looking for answers? Try searching our database.

query from multiple tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lana - 14 Aug 2006 08:30 GMT
Hi all,

I got a table "tCorrespondence" where i have lots of combo-fields linked to
sub-tables.
Somebody told me to store the reference number (id from sub-table) but not
actual text in the fields of main table. Which i did, and all was fine with
Forms and Reports where i also used combo-boxes, - untill i came to a need to
have all values to be represented in 1 query as text fields (for output to a
Word template using mail-merge).

I successfully got data from main table and 1 sub-table, but when i try to
add more sub-tables, i get unexpected results.

I was making the query in the "Design view" and when i switched to SQL i saw
that
the function used is "INNER JOIN". May be it is wrong?

Please help!!!!

SELECT tCorrespondence.ID, tCorrespondence.IssueDate,
tCorrespondence.RecDelDate, tCorrespondence.Type, tCorrespondence.RefNo,
tCorrespondence.MeanOfDelivery, tCorrespondence.FromToClient,
tCorrespondence.Project, tCorrespondence.Subject, tCorrespondence.FiledAt,
tCorrespondence.PriceVND, tCorrespondence.DocType, tCorrespondence.FollowUp,
tContacts.CompID, tContacts.CompanyFullName, tContacts.BusinessStreet,
tContacts.BusinessCity, tContacts.BusinessCountry, tCorrespondence.ToPerson,
tCorrespondence.DHLNo, tCorrespondence.Comments,
tCorrespondence.PersonSigned, tCorrespondence.CommentsW
FROM tContacts INNER JOIN tCorrespondence ON tContacts.CompID =
tCorrespondence.FromToClient
WHERE (((tCorrespondence.Type)=2));

The above code works all right, but i need to introduce data from
"tContactPersons" and "tProjects" to replace there "IDs" stored in the main
table. How can i do that?

Thank you.
Lana
Jeff Boyce - 14 Aug 2006 13:45 GMT
Lana

From your description, it sounds like your tCorrespondence has "lookup" data
fields ("lots of combo-fields linked to sub-tables").  You may be
encountering one of the problems folks run into by using the lookup data
type, instead of using a numeric or text data type, holding the key value
(i.e., the foreign key) from the other tables.  I believe you called this
the "reference number" or the "id from sub-table".

Have you opened a query in design mode and tried adding the additional
tables, then modifying the join between them to take all of the "main" table
records and "any" of the sub-table records?

Signature

Regards

Jeff Boyce
Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/

> Hi all,
>
[quoted text clipped - 34 lines]
> Thank you.
> Lana
Cinzia - 14 Aug 2006 13:52 GMT
> Hi all,
>
[quoted text clipped - 34 lines]
> Thank you.
> Lana

Hi Lana,
probably you have to change the INNER JOIN with LEFT JOIN.
To Do this in Design View :
click with left mouse button on  each line joining the Table with the
sub-table, Select Property  from the menu and Choose the right option,
usually the second one: "Select All rows from Table and only the rows from
subTable ....where...."

Bye
Signature

Cinzia
---------------------------------------

|  http://www.riolab.org  |
---------------------------------------
Lana - 15 Aug 2006 06:14 GMT
Thank you guys,

I have revised all links between my tables and now it works all right.

Somehow Access assigned its own links when I add tables in the query design
- absolutely different from what i have assigned in "Relationships" page.
Now i will double check this when making queries.

Thanks again!
Lana

> > Hi all,
> >
[quoted text clipped - 54 lines]
> |  http://www.riolab.org  |
> ---------------------------------------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.