私が使用しているコード:
Dim rs As New ADODB.Recordset
rs.Open "select * from QueryName", CurrentProject.Connection, adOpenDynamic, adLockReadOnly
なぜこれがオープンエラーを返すのですか? クエリ自体はまったく問題ありません。
クエリ、ところで:
SELECT DISTINCT Zone.Office, ledger.representative
FROM ledger LEFT JOIN [Zone] ON ledger.branch = Zone.app_office
WHERE (((Zone.Office)<>"" And (Zone.Office) Is Not Null) AND ((ledger.representative)<>"" And (ledger.representative) Is Not Null))
UNION SELECT DISTINCT Zone.Office, ClientList.representative
FROM ClientList LEFT JOIN [Zone] ON ClientList.branch = Zone.app_office
WHERE (((Zone.Office)<>"" And (Zone.Office) Is Not Null) AND ((ClientList.representative)<>"" And (ClientList.representative) Is Not Null))
UNION SELECT DISTINCT Zone.Office, ghs.representative
FROM ghs LEFT JOIN [Zone] ON ghs.branch = Zone.app_office
WHERE (((Zone.Office)<>"" And (Zone.Office) Is Not Null) AND ((ghs.representative)<>"" And (ghs.representative) Is Not Null))
UNION SELECT DISTINCT Zone.Office, Prospects.representative
FROM Prospects LEFT JOIN [Zone] ON Prospects.branch = Zone.app_office
WHERE (((Zone.Office)<>"" And (Zone.Office) Is Not Null) AND ((Prospects.representative)<>"" And (Prospects.representative) Is Not Null))