ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Query Results (https://www.excelbanter.com/excel-programming/282187-query-results.html)

Michael Burkett

Query Results
 
This may be a question that needs to be addressed in an Access group
but here it goes.

I have 2 tables (Client & Group) Some of the records in the Client
table are also part of a group which are coded as such in the Group
table. My problem is when I try to pull in data from both tables in
Access with MS Query (To MS Excel) it only pulls in data if the
records are part of a group. I am not filtering the data so I am not
sure why it is not pulling in the data.

Dick Kusleika[_3_]

Query Results
 
Michael

It sounds like a problem with the SQL statement. Go to the VBE (alt-F11)
and in the immediate window (Cntl-G) look at the SQL string. Type something
like this

?Sheet1.QueryTables(1).CommandText

That will print the SQL. If you see INNER JOIN in your SQL, then you've
found the problem. An inner join will only pull records if the fields match
both tables. If you want all the records from the first table and only
those that match from the second table, then you want a LEFT JOIN. There is
also a RIGHT JOIN.

If that turns out to be the problem, the way that would fix it is to go into
Access and set up a query that gives the results I want. Then look at the
SQL for that query. You can then put that in your Excel querytable via the
immediate window:

Sheet1.QueryTables(1).CommandText = "SELECT... <paste the sql here"

You can also edit your External Data in MSQuery and paste the SQL into its
SQL View.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Michael Burkett" wrote in message
m...
This may be a question that needs to be addressed in an Access group
but here it goes.

I have 2 tables (Client & Group) Some of the records in the Client
table are also part of a group which are coded as such in the Group
table. My problem is when I try to pull in data from both tables in
Access with MS Query (To MS Excel) it only pulls in data if the
records are part of a group. I am not filtering the data so I am not
sure why it is not pulling in the data.





All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com