从查询引用子窗体 [英] Referring to a Subform from a Query

查看:138
本文介绍了从查询引用子窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MS Access 2010中,我有一个查询,该查询在条件中引用了以下内容;

In MS Access 2010, I have a Query which quotes the following in the Criteria;

[Forms]![frm_Add_Item_Subform].[ActiveControl].[Caption]

这使我可以在查询中使用按钮的标题"文本.按钮上的以下代码用于捕获点击.

This lets me use the "Caption" text of a Button within the query. The following code is on the Button to capture the click.

Private Sub cmdClickMe_Click()
Debug.Print Me.cmdClickMe.Caption
Debug.Print Screen.ActiveControl.Caption
End Sub

我在下面的StackOverflow URL上获得了有关如何执行此操作的信息. 使用来自查询其他形式的主要形式

I obtained information on how to do this at the following StackOverflow URL. use caption of pressed button from main form in query of other form

在窗体中使用时,该功能可以正常使用.但是在Subform(我需要在其中使用它)中使用它时就不行了.我相信我需要调整查询条件以正确引用子窗体的帮助.

The functionality works ok when used in a Form. But doesn't when its used within a Subform (which is where I need to use it). I believe I need help tweaking the Query Criteria to refer to the Subform correctly.

希望有人可以为此提供一些指导.预先感谢!

Hoping someone will be able to give me some guidance on this. Thanks in advance!

P.S.表单的主要名称是"frm_Add_Item_Main"

P.S. The main Form name is "frm_Add_Item_Main"

推荐答案

这是指子表单的方式:

Forms!mainFrm!subFormControlName.Form

所以您需要:

Forms!mainFrm!subFormControlName.Form.ActiveControl.Caption

其中subFormControlName是主窗体中子窗体控件的名称(不是子窗体的名称)(显示在主窗体中选择子窗体控件的时间)

where subFormControlName is the name of the subform control (not the name of the subform) in the main form (it shows when the subform control is selected in the main form)

这篇关于从查询引用子窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆