1

私が使用しているコード:

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))
4

1 に答える 1

3

Microsoft DAO x.x Object Libraryまたは 2010 年 (または 2007 年?) 以降への参照が必要になります。Microsoft Office x.x Access Database Engine Object Library

Dim rs As DAO.Recordset

Set rs = CurrentDB.OpenRecordset("NameOfquery")
于 2012-10-25T14:35:11.933 に答える