具有动态记录源的数据表在 Access 2007 中不显示任何记录,但在 Access 2003 中有效

发布于 2024-09-16 07:47:01 字数 644 浏览 2 评论 0原文

我有一个 Access 2003 数据库,它使用主窗体和子窗体中的数据表。主窗体允许用户从更新子窗体记录源的菜单中进行选择。子表单还根据表单记录源中的字段数量和类型更新可编辑的字段数量和类型。它基本上是一个动态数据表生成器。这在 Access 2003 中运行良好,并且多年来一直如此。如果我在 Access 2007(完整版或运行时版)中打开相同的数据库,则大多数菜单选项都有效。但是,如果我选择引用一个特定表的任何菜单选项,子窗体将显示列标题,但不会显示任何数据行或显示任何错误。就好像查询返回零行。为什么 Access 2007 中会有差异?他们添加了新的保留字吗?

我尝试过的事情:

  • 更新表中的每个字段以确保没有空值(没有更改)
  • 重命名每个字段和表名称,以防出现新的保留字(没有更改)
  • 压缩并修复前端和后端结束(无变化)
  • 尝试一一包含和排除字段以查看是否有任何更改(无变化)
  • 将表单的记录源放入新查询中。 (它返回了预期的行数)
  • 已检查以确保表单未设置为数据输入模式。 (不是)
  • 检查以确保代码中没有应用任何过滤器。 (没有)
  • 已检查以确保查询在 Access 2007 中可更新。(是)
  • 有选择地从源表中删除了数据块。 (没有变化)

我被难住了。

I have an Access 2003 database which uses a main form with a datasheet in a subform. The main form allows the user to select from a menu which updates the recordsource of the subform. The subform also updates the number and type of fields available for editing based on the number and types of fields in the form's recordsource. It's basically a dynamic datasheet generator. This works just fine in Access 2003 and has been for years. If I open the same database in Access 2007 (full or runtime), most of the menu selections work. However, if I choose any menu option that references one particular table, the subform shows column headers, but does not show any rows of data or display any errors. It's as if the query is returning zero rows. Why would there be a difference in Access 2007? Did they add new reserved words?

Things I've tried:

  • Updated every field in the table to ensure there are no null values (no change)
  • Renamed every field and the table name just in case there are new reserved words (no change)
  • Compacted and repaired the front end and back end (no change)
  • Tried including and excluding fields one by one to see if anything changed (no change)
  • Put the form's recordsource in a new query. (it returned the expected number of rows)
  • Checked to make sure the form is not set to data entry mode. (It's not)
  • Checked to ensure that no filters were being applied in code. (none were)
  • Checked to make sure the query is updateable in Access 2007. (It is)
  • Selectively deleted chunks of data from the source table. (no change)

I'm stumped.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

知你几分 2024-09-23 07:47:01

我终于能够解决这个问题。正如我上面指出的,我的数据表是一个子表单。父窗体设置确定如何构建子窗体的选项。在构建数据表时,子窗体的源对象将替换为空白窗体,以隐藏先前的数据表并呈现到新数据表的平滑过渡。它在 Access 2000/2003 中运行良好。

当 Access 2007 中的空白表单替换为新数据表时,我发现Access 会自动将子表单数据的主键分配给未绑定父表单的 LinkMasterFields 和 LinkChildFields 属性。这些属性以前是空白的,我从未在代码中设置它们。也许这是 Access 2007 试图提供帮助的尝试,而不是一个错误,但我能找到的任何技术参考(包括内置帮助文件)都没有指出行为差异。由于父表单未绑定,它具有过滤掉所有我的子表单记录的效果。如果我在表单替换步骤中显式设置 LinkMasterFields="" 和 LinkMChildFields="",则一切都会像以前一样工作。万岁!

同样,解决方案是,在设置子表单的 sourceobject 时,请务必显式设置 linkmastfields 和 linkchildfields 属性,以防止 Access 为您执行此操作。我希望这可以帮助别人摆脱我所经历的沮丧时光。

I was able to finally resolve the issue. As I noted above, my datasheet is a subform. The parent form sets the options that determine how the subform will be built. While the datasheet is being built, the subform's sourceobject is replaced with a blank form to hide the prior datasheet and present a smooth transition to the new datasheet. It works beautifully in Access 2000/2003.

When the blank form is replaced with the new datasheet in Access 2007, I found that Access is automatically assigning the primary key of the subform data to the LinkMasterFields and LinkChildFields properties of the unbound parent form. Those properties had previously been blank, and I never set them in code. Perhaps this is as an attempt by Access 2007 to be helpful rather than a bug, but the behavior difference is not noted in any tech reference I can find, including the built-in help file. Since the parent form is unbound, it has the effect of filtering out all of my subform records. If I explicitly set LinkMasterFields="" and LinkMChildFields="" during the form substitution step, everything works as it did before. Hooray!

Again, the solution is that when setting the sourceobject of a subform, be sure to explicitly set the linkmastfields and linkchildfields properties to prevent Access from doing it for you. I hope this saves someone the hours of frustration I experienced.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文