2

我刚刚将 ACCESS 数据库(后端)导入到 SQL Server 2008 数据库。我的前端仍然是 ACCESS 2007,后端是 SQL Server 2008。我意识到,如果我打开一个表单(在某条记录上)然后进行一些应该填写一些文本字段的计算自动在该表单上(对于该记录),那么这些文本字段的值此时不会填写。现在,如果我关闭表单并为同一条记录重新打开它,值就在那里。所以就像延迟一样,这阻止了其他事情的发生。有人可以帮我解决这个问题吗?我尝试使用 ODBC 驱动程序 SQL Server 以及 SQL Server Native Client 10.0,但它们都不起作用。

非常感谢

4

2 回答 2

1

Most features in a form work the same when using local tables or linked ones to sql server.

However one significant difference here is that even when you start editing information in a form in add mode the primary key is INSTANLTY added in a local form. This means if there’s any kind of lookups, perhaps even sub forms, or other expressions that are based on using the primary key, these displays will be instantly updated when you’re running a local edition of MS access and you start to type.

However when using linked tables to SQL server, the auto number primary key ID is not generated untill the record is actually saved. Therefore you should check these expression(s) if they use and rely on the primary key for their display of information.

If the above is your problem, then perhaps in one of the controls that a user common enters data you force a disk write (and thus force generation of the Primary key).

So in the “after update” event of a major textbox (field) you enter, you can force a disk write such as:

If isnull(me!id) = true then
   ‘ we have no primary key, force a disk write
   If me.Dirty = false then
      Me.Dirty = true
   End if
End if

You might want to expand and give a few more details as to what kind of expressions are not working. However, the above is to most significant difference in the sequence of what point in time the primary key is created and becomes available to other expressions on the form.

于 2009-07-07T01:28:36.397 回答
1

对于服务器后端,Access 需要帮助以使表单保持最新。首先,每个表都需要一个主键(没有设计得当的表缺少主键,但这可能是一种适用于 Jet 并在升级到 SQL Server 或任何其他 ODBC 后端时中断的东西)。其次,我发现向所有 SQL Server 表添加时间戳字段是一种很好的做法,因为这允许 Access 知道记录是否已更新,而无需评估记录中的每个字段。这也使得 Access 可以在不做太多额外工作的情况下刷新表单中的显示缓冲区。

于 2009-07-07T02:01:34.130 回答