6

We have a fairly large Access front-end application that has been running on Access 2010. It makes extensive use of ADO recordsets for accessing data on our SQL servers, and frequently uses the UniqueTable form property.

We are looking to move the whole office to Office 2013 early next year, but during testing we have found that Access 2013 will not work with our code that uses UniqueTable. Any attempt to set UniqueTable results in the error message:

You entered an expression that has an invalid reference to the property UniqueTable

The following code works on Access 2010 but encounters above error on Access 2013 when attempting to set UniqueTable:

dim conn AS New ADODB.Connection
conn.ConnectionString = "DATA PROVIDER=SQLOLEDB;DATA SOURCE=server1;DATABASE=database1;Integrated Security=SSPI;"
conn.CursorLocation = adUseServer
conn.Provider = "MSDataShape"
conn.Open

Dim cmd As New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
cmd.CommandText = "SELECT TOP 10 * FROM Members WHERE MemberID IS NOT NULL"

cmd.Execute

Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenKeyset, adLockOptimistic

Set Recordset = rs
UniqueTable = "Members"

While searching for a solution I have found only a couple of other cases where this error has been mentioned, and no solutions so far.

4

3 回答 3

1

您可以设置 Recordset.Properties("Unique Table"),例如:

rs.Properties("Unique Table") = "members"

请参阅ADO 动态属性

于 2015-03-02T02:12:19.433 回答
1

恐怕你在这件事上可能不走运。我能够重新创建您的问题:UniqueTable在 Access 2010 中成功设置表单属性的代码在 Access 2013 中失败,并显示相同的运行时错误消息。

谷歌搜索microsoft access uniquetable会产生一些命中,其中绝大多数是指在ADP中使用该表单属性。ADP 支持已从 Access 2013中完全UniqueTable删除,所以我猜测该支持也随之删除。(Access 2013 VBA 编辑器中的 IntelliSense 功能仍然Me.UniqueTable作为 Form 对象的属性提供,但 Access 2013 显然不允许我们在运行时为其设置值。)

于 2014-01-04T20:07:05.103 回答
0

您仍然可以使用 Me.UniqueTable 来确保在从多表中删除数据时选择加入 ADO 记录集的工作正常。me.ResyncCommand 也在 VBA 代码中工作,不再作为表单设计中的属性,而是在表单加载等代码中的表单后面。

于 2014-09-17T11:36:17.707 回答