MS Access查询:检查表单是否打开/检查参数是否需要输入 [英] MS Access Query : Check if form is open / Check if parameter requires input

查看:49
本文介绍了MS Access查询:检查表单是否打开/检查参数是否需要输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在MS Access查询(使用GUI工具而非SQL工具)中,而不使用VBA来检查是否打开了特定表单.

I'm currently trying, in a MS Access Query (using the GUI tool, and not the SQL tool), to check if a specific form is open or not, without using VBA.

使用以下表达式:

Expr1 : [Formulaires]![Form1].[Visible]

如果打开了Form1,则查询工作正常,但是如果关闭了Form1,则它会要求输入,因为Form1没有打开,并且该变量不再存在.

If Form1 is open, the query works fine, but if Form1 is closed, it asks for input, since the Form1 isn't open, and the variable doesn't exist anymore.

是否可以检查是否打开了特定的表单,或者检查某个变量是否需要输入?

Is there a way to check if a specific form is open, or to check if a certain variable requires input ?

推荐答案

您将需要VBA函数来发现此问题,但是您可以从查询中调用该函数并将结果合并到公式中.

You would need a VBA function to discover this but you could call the function from your query and incorporate the result in your formula.

如果加载了表单,此函数将返回true;

This function will return true if the form is loaded;

Function IsFormLoaded(strForm As String) As Boolean

Dim frm As Form

For Each frm In Forms
    If frm.Name = strForm Then
        IsFormLoaded = True
        Exit Function
    End If
Next

End Function

然后您可以在IIF语句中使用该函数;

You can then use the function in an IIF statement;

IIF(IsFormLoaded('MyForm'), MyForm.Control.Value, '')

这篇关于MS Access查询:检查表单是否打开/检查参数是否需要输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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