MS Access 2007 将表单转换为子表单 - “找不到表单”问题

发布于 2024-09-10 09:19:51 字数 555 浏览 8 评论 0原文

所以我最近一直在尝试合并更多的子表单,让UI更加友好。因此,我有一个运行一些 VB 的预先开发的表单,因此,为了举例,我们只说它运行 SQL 语句、返回记录集,并用数据填充文本框(因为这是一种交互式仪表板概念:

dim db as database
dim rs as recordset
dim sql as string
set db = current db

sql = "SELECT * FROM tblMain;"

   set rs = db.OpenRecordSet(sql)

         rs.movefirst
             [forms]![DashboardSubName].txtValue1 = rs!Value1
         rs.close

 set rs = nothing
 set db = nothing

具有错误处理功能)返回错误“DashboardSubName”未找到。所以最初这个表单是它自己的表单,并且单独打开它它工作正常,但是一旦我在父表单中使用它,我确信

这只是我的问题 。不知道,但是

谢谢大家 ? 贾斯汀

So I recently have been trying to incorporate more sub forms to make the UI more friendly. So I have a pre developed form that runs some VB, so for examples sake lets just say that it runs SQL statement, returns the recordset, and fills text boxes with the data (because this is sort of an interactive dashboard concept:

dim db as database
dim rs as recordset
dim sql as string
set db = current db

sql = "SELECT * FROM tblMain;"

   set rs = db.OpenRecordSet(sql)

         rs.movefirst
             [forms]![DashboardSubName].txtValue1 = rs!Value1
         rs.close

 set rs = nothing
 set db = nothing

with error handling that returns a error "DashboardSubName" not found. So orginally this form was its own form, and opening it by itself it works fine, but once I use it within the parent form i get this error.

im sure it is simply something i am not aware of, but what gives?

thanks guys
justin

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

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

发布评论

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

评论(3

红ご颜醉 2024-09-17 09:19:51

当表单作为子表单加载时,它会被引用,就好像它只是主表单上的另一个控件一样 - 它不再是全局 Forms 集合的一部分。

所以正确的参考应该是:
Me!DashboardSubName.Form.txtValue1

,其中 DashboardSubName 是子表单控件的名称。

When a Form is loaded as a sub-form, it is referenced as if it were just another control on the Main Form - it is no longer part of the global Forms collection.

So the correct reference should be:
Me!DashboardSubName.Form.txtValue1

where DashboardSubName is the name of your sub-form control.

青衫负雪 2024-09-17 09:19:51

假设您向我们展示的代码是子表单的一部分,而不是父表单的一部分,请替换

[forms]![DashboardSubName].txtValue1 = rs!Value1

Me.txtValue1 = rs!Value1

Assuming the code you showed us is part of the subform, rather than the parent form, replace

[forms]![DashboardSubName].txtValue1 = rs!Value1

with

Me.txtValue1 = rs!Value1
只等公子 2024-09-17 09:19:51

这里使用语法的原因是子窗体控件与嵌入其中的子窗体不同。子表单控件具有其自己的属性(与子表单本身相比受到限制),并且要获取嵌入其中的子表单的属性/方法,您必须指定您想要子表单嵌入的表单。

  Me!MySubformControl

...是子表单控件。

  Me!MySubformControl.Form

...是嵌入在子表单控件中的表单。

最后,我真的很想知道为什么要遍历记录集来更新子表单中的数据。这不是正常做法,尽管它与您的实际问题无关。

The reason for the syntax here is that the subform control is distinct from the subform embedded inside it. The subform control has properties of its own (limited in comparison to the subform itself), and to get to the properties/methods of the subform embedded in it you have to specify that you want the form that the subform embeds.

  Me!MySubformControl

...is the subform control.

  Me!MySubformControl.Form

...is the form embedded in the subform control.

Last of all, I really wonder why you're walking a recordset to update data in a subform. This is not normal practice, though it's tangential to your actual question.

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