错误 2427 “您输入的表达式没有值。” 以访问形式 (VBA)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28680210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 06:20:11  来源:igfitidea点击:

Error 2427 "You entered an expression that has no value." in Access form (VBA)

formsvbams-accessaccess-vbams-access-2010

提问by Yahia El Haddad

I am using Access VBA, and I have two forms (form1 and form2), in form 1 I have a listbox control (form1.modifiable49). I choose a list item and with a button control click I open the second form (form2),

我正在使用 Access VBA,并且我有两个表单(form1 和 form2),在表单 1 中我有一个列表框控件(form1.modifiable49)。我选择一个列表项,然后使用按钮控件单击我打开第二个表单 (form2),

In the second form I have some table columns, and I have a textbox where I store my variable, I would like to open form2 with the element that equals the value of modifiable49

在第二个表单中,我有一些表格列,我有一个文本框来存储我的变量,我想用等于 modifiable49 的值的元素打开 form2

I have:

我有:

Private Sub Form_Load()
    Me.Texte = [Forms]![Form1]![Modifiable49]
    Me.Filter = "[id_parcelle]=" & Texte
    Me.FilterOn = True
End Sub

but when I choose the value in the listbox and I excute I get error 2427:

但是当我选择列表框中的值并执行时,我收到错误 2427:

You entered an expression that has no value.

The expression may refer to an object that has no value, such as a form, a report, or a label control.

您输入了一个没有值的表达式。

表达式可能指代没有值的对象,例如窗体、报表或标签控件。

回答by Gustav

This will not fail and will list the value of Texte for you to investigate:

这不会失败,并将列出 Texte 的值供您调查:

Private Sub Form_Load()
    Me!Texte.Value = [Forms]![Form1]![Modifiable49].Value
    Debug.Print "Texte:", Me!Texte.Value
    Me.Filter = "[id_parcelle]=" & Me!Texte.Value & ""
    ' or, if Texte is a string:
    ' Me.Filter = "[id_parcelle]='" & Me!Texte.Value & "'"
    Me.FilterOn = Not IsNull(Me!Texte.Value) 
End Sub