Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问VBA参考活动窗体上的文本框_Vba_Ms Access - Fatal编程技术网

访问VBA参考活动窗体上的文本框

访问VBA参考活动窗体上的文本框,vba,ms-access,Vba,Ms Access,我知道如何通过选择表单来引用表单上的项目,即表单!frmMyForm![控制]。值。但我有一个代码,它可以找到哪个表单是打开的,然后从那个变量执行代码,但它不起作用。我想我只需要使用ActiveForm引用控件,而不是显式的表单名称,但是我尝试完成的事情没有成功 这是我的密码 Private Sub OrderButton_Click() ' DoCmd.SetWarnings False ' CurRecord = Forms!frm_EC_All![L#].Value GetID = For

我知道如何通过选择表单来引用表单上的项目,即
表单!frmMyForm![控制]。值
。但我有一个代码,它可以找到哪个表单是打开的,然后从那个变量执行代码,但它不起作用。我想我只需要使用ActiveForm引用控件,而不是显式的表单名称,但是我尝试完成的事情没有成功

这是我的密码

Private Sub OrderButton_Click()
'
DoCmd.SetWarnings False
'
CurRecord = Forms!frm_EC_All![L#].Value
GetID = Forms!frm_MainMenu!AssocIDBox
'
Me.LBox.Value = CurRecord
'
If CurrentProject.AllForms("frm_EC_All").IsLoaded = True Then
    RightForm = "frm_EC_All"
ElseIf CurrentProject.AllForms("frm_EC_EC#").IsLoaded = True Then
    RightForm = "frm_EC_EC#"
ElseIf CurrentProject.AllForms("frm_EC_Holds").IsLoaded = True Then
    RightForm = "frm_EC_Holds"
ElseIf CurrentProject.AllForms("frm_EC_L1").IsLoaded = True Then
    RightForm = "frm_EC_L1"
ElseIf CurrentProject.AllForms("frm_EC_L1_L2").IsLoaded = True Then
    RightForm = "frm_EC_L1_L2"
ElseIf CurrentProject.AllForms("frm_EC_L2").IsLoaded = True Then
    RightForm = "frm_EC_L2"
ElseIf CurrentProject.AllForms("frm_EC_L34").IsLoaded = True Then
    RightForm = "frm_EC_L34"
End If
'
Me.Refresh
'
DoCmd.RunSQL "UPDATE tbl_CQueue SET Order1 = -1, Order1Date = Now WHERE [L#] = " & CurRecord
DoCmd.Close acForm, "frm_Requests", acSaveYes
DoCmd.Close acForm, RightForm, acSaveYes
'
DoCmd.OpenForm RightForm, acNormal, , , , acWindowNormal
'
Dim CurrentForm As Form: Set CurrentForm = Screen.ActiveForm
MsgBox "Current form is " & CurrentForm.Name
'
CurrentForm.TimerActivatedLabel.Visible = True
'
GetID = Forms!frm_MainMenu!AssocIDBox
CurRecord = Forms!CurrentForm![L#].Value
'
DoCmd.RunSQL "UPDATE tbl_Data SET tbl_Data.[AssocID] = " & GetID & " , tbl_Data.[tsStartAll] = Now WHERE tbl_Data.[AssocID] Is Null AND tbl_Data.[L#] = " & CurRecord
'
Forms!CurrentForm!IDFieldBox.Value = GetID
'
DoCmd.SetWarnings True
'
End Sub
我在
CurrentForm.TimerActivatedLabel.Visible=True
行中得到一个错误。错误显示
“数据库找不到宏表达式或Visual Basic代码中引用的“CurrentForm”表单。”

因此,它在后台看到打开的表单,并将其存储为“RightForm”,然后关闭该表单,再次打开它,然后尝试使其工作,我将活动表单设置为
CurrentForm
,然后它应该设置一些文本框并运行SQL语句,等等,但是它需要知道表单的名称,并且没有正确地抓取
CurrentForm
作为表单的名称


有什么想法吗?谢谢。

woops,我在发布后就找到了答案

Screen.ActiveForm![TimerActivatedLabel].Visible = True
这对我来说很有用

无论如何谢谢你

你需要学习。如果知道了这一点,这个问题就过时了o)