微软访问。子表单的 ADO 记录集。以编程方式建立子关系。不会自动填写字段
我有一个用于将数据输入 ado 表的表单/子表单。主窗体的记录集是一个本地小部件表和有关小部件的信息(小部件ID、小部件名称、大小、颜色、位置等)。我通过子表单输入测试数据(每个小部件有多个测试,所有测试都具有唯一的日期),该子表单连接到 ADO 记录集并连接到名为 Tests 的表。我在主窗体中有一个组合框 findWidget,用户可以在其中选择 WidgetID,并更新主窗体上的一些信息。我还编写了 VBA 代码来完成父/子关系的工作,以更改子窗体的记录集以仅显示与该 WidgetID 相对应的测试。但是,子表单中有一个 WidgetID 字段,当我在主表单中选择 WidgetID 时,我希望自动填写该字段。这在我应用 ADO 记录集(我使用两个本地表)并且设置父/子关系之前就起作用了。然而,对于 ADO 来说,父/子似乎不起作用,所以我必须对其进行 vba。这是我尝试过的代码,这是子表单加载时的代码:私有子表单_Load()
Me.UCI = Forms!InputMainForm.findWidget
结束子
代码执行时没有错误,但子窗体中的控件未更新。加载表格后它只是空白。也许代码应该在 findWidget 组合更新后?我不知道。如果我把它放在那里,我不太确定如何引用子窗体的控件。有什么想法吗?
谢谢。
I have a form/subform for inputting data into an ado table. The main form's recordset is a local table of Widgets and information about the widgets (WidgetID, WidgetName, size, color, location, etc). I am inputting test data (multiple tests per widget, all with unique dates) through the subform which is connected to an ADO recordset to a table called Tests. I have a combo box, findWidget, in the main form where the user can choose a WidgetID and it updates some info on the main form. I have also written VBA code to do the job of the parent/child relationship to change the recordset of the subform to only show the Tests that correspond to that WidgetID. However, There is a field for the WidgetID in the subform that I would like to be filled in automatically when i choose the WidgetID in the main form. This just worked before I applied the ADO recordset (i was using two local tables), and I set up a parent/child relationship. However, with ADO it seems parent/child doesn't work so I have to vba it. Here is the code I have tried, this is for when the subform loads:Private Sub Form_Load()
Me.UCI = Forms!InputMainForm.findWidget
End Sub
The code executes with no errors, but the control in the subform is not updated. It is just blank upon loading the form. Maybe the code should be in the after update of the findWidget combo? I dont know. If I put it there I'm not really sure how to refer to the controls of the subform. Any ideas?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修好了。我只是将子窗体中的控件的默认值设置为等于主窗体中的控件。我还将子窗体控件设置为锁定,以便用户无法选择不同的小部件。这意味着整个界面中只有一个地方可供用户选择小部件,那就是主窗体中(findWidget)
fixed it. I just set the default value of the control in the subform to be equal to the control from the main form. I also set the subform control to be locked so the user couldnt choose a different widget. this means that there is only one place in the whole interface for the user to choose a widget and that is in the main form (findWidget)