Thanks for the discussion and suggestions. What I am trying to accomplish
is not only difficult but is also difficult to explain. In an attempt to
clarify my question I am providing part of my tables below with my latest
successful results. In researching this further I realized that I needed to
first create and run a query to select only the LiquorOrders.OrderNumberID
that I was interested in. For the example below, I queried the
LiquourOrders Table LiquorOrders.OrderNumberID =2 directly in Access with
the following sql:
LiquorOrdersQuery:
SELECT LiquorOrders.*
FROM LiquorOrders
WHERE (((LiquorOrders.OrderNumberID)=2));
I then created a second Query linking the Liquor table with the
LiquorOrdersQuery
TheQuery:
SELECT Liquor.*, LiquorOrdersQuery.*
FROM Liquor LEFT JOIN LiquorOrdersQuery ON Liquor.LiquorID =
LiquorOrdersQuery.LiquorID;
This gave me the desired results of creating a recordset that contained all
items from my Liqour Table with order details from LiqourOrders table that
matched the criteria of LiquorOrders.OrderNumberID =2 (or any OrderNumberID
I specify). While these results represent what I wanted to accomplish it
however creates a whole new dilemma. How do I use this in Excel VBA. It
would appear that both queries should be combined and run as a single query
but I have not been able to find any information on how to make this happen.
What I am trying to do using Excel 2000 in VBA is create a recordset (like
below) that will list all items from Table1 and additional fields from table
2 that are linked using a left join on an ID field. I would appreciate any
suggestions on what this should look like. I have included a simple test
macro I am using to check results in Excel. The sql statements are taken
from Access and need to be combined or changed to achieve the desired
recordset.
Sub JoinIt()
Dim sql As String
Dim x As Byte
Dim recLO As New Recordset
'
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
ThisWorkbook.Path & "\liqOrder.mdb;Jet OLEDB

atabase;"
'
'this code needs to be combined to create a "Query on Query"
sql = "SELECT LiquorOrders.* FROM LiquorOrders WHERE
(((LiquorOrders.OrderNumberID)=2))"
sql = "SELECT Liquor.*, LiquorOrdersQuery.* FROM Liquor LEFT JOIN
LiquorOrdersQuery ON Liquor.LiquorID = LiquorOrdersQuery.LiquorID"
'
recLO.Open sql, conn, adOpenKeyset, adLockReadOnly
'
For x = 1 To recLO.RecordCount
MsgBox x & " of " & recLO.RecordCount & " " & recLO!Item & " " &
recLO!OrderNumberID & " " & recLO!OrderStamp
recLO.MoveNext
Next x
If recLO.State = 1 Then recLO.Close
If conn.State = 1 Then conn.Close
'
End Sub
Liquors (table 1 LEFT side)
LiquorID Item Par Unit Cost Stock DateAdded DateCancelled Status
1 Amaretto 6 1 $1.99 123456 04-Nov-03 TRUE
2 Bailey's Irish Cream 6 1 $1.99 123456 04-Nov-03 TRUE
3 Cabernet Sauvignon, BV Coastal 48 1 $1.99 123456 04-Nov-03 TRUE
4 Chambord 3 1 $1.99 123456 04-Nov-03 TRUE
5 Chardonnay, Chateau St. Michelle 60 1 $1.99 123456 04-Nov-03 TRUE
6 Courvoisier, VSOP 3 1 $1.99 123456 04-Nov-03 TRUE
7 Frangelico 6 1 $1.99 123456 04-Nov-03 TRUE
8 Godiva Chocolate Liqueur 3 1 $1.99 123456 04-Nov-03 TRUE
LiquorOrders (table 2 RIGHT side)
DateID OrderNumberID LiquorID Ordered Received OrderStamp CastID
ReceivedStamp ReceivedCastID
11/1/2003 1 8 1 1 11/1/2003 17:01 jper001 11/12/2003 9:01 jper001
11/30/2003 2 4 1 11/30/2003 10:04 jper001
11/30/2003 2 8 2 2 11/30/2003 10:04 jper001 12/3/2003 12:01 jper001
11/30/2003 2 10 3 3 6/23/2004 10:44 jper001 6/23/2004 10:45 jper001
11/30/2003 2 13 1 1 11/30/2003 10:04 jper001 6/23/2004 10:43 jper001
12/2/2003 3 1 1 12/2/2003 16:01 jper001
12/2/2003 3 3 3 12/2/2003 16:01 jper001
12/2/2003 3 4 4 12/2/2003 16:01 jper001
12/2/2003 3 5 5 12/2/2003 16:01 jper001
12/2/2003 3 7 7 12/2/2003 16:01 jper001
Recordset (this is what I want to accomplish)
Liquor.LiquorID Item Par Unit Cost Stock Status DateID OrderNumberID
Ordered Received OrderStamp CastID ReceivedStamp ReceivedCastID
1 Amaretto 6 1 $1.99 123456 TRUE
2 Bailey's Irish Cream 6 1 $1.99 123456 TRUE
3 Cabernet Sauvignon, BV Coastal 48 1 $1.99 123456 TRUE
4 Chambord 3 1 $1.99 123456 TRUE 11/30/2003 2 1 11/30/2003 10:04
jper001
5 Chardonnay, Chateau St. Michelle 60 1 $1.99 123456 TRUE
6 Courvoisier, VSOP 3 1 $1.99 123456 TRUE
7 Frangelico 6 1 $1.99 123456 TRUE
8 Godiva Chocolate Liqueur 3 1 $1.99 123456 TRUE 11/30/2003 2 2 2
11/30/2003 10:04 jper001 12/3/2003 12:01 jper001
Thanks again for your suggestions,
Joseph