本文介绍了Access Query中的全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在访问查询中使用全局变量作为标准。

在我第一次尝试这样做时我写了一个看起来像这样的函数


公共函数GloVar(ByVal VarName)字符串


GloVar = VarName


结束函数


它没用。

它计算变量名的文本而不是变量的值。 Additionaly访问强制VarName在引号中。如果我输入GloVar(JobNo),它会自动更改为GloVar(JobNo)。


我读了大约一年前的帖子,建议对每个变量使用If语句。即


如果VarName =" JobNo"然后

GloVar = JobNo


我(作为原始海报)希望有一个更通用的功能,可以检索输入的任何变量的值为每个变量引入一个if语句。


任何帮助都将不胜感激。


Megan

I would like to use a Global variable as a criteria in an access query.
in my first attempt to do so I wrote a Function that looks like this

Public Function GloVar(ByVal VarName) As String

GloVar = VarName

End Function

It Didn''t Work.
It evaluates to the text of the variable name not the value of the variable. Additionaly access forces the VarName to be in quotes. If I Type GloVar(JobNo) it automatically changes to GloVar("JobNo").

I read a post from about a year ago that suggested using an If statement for each variable. i.e.

If VarName = "JobNo" Then
GloVar = JobNo

I (as the original poster) was hoping for a more universal function that would retrieve the value of whatever variable was entered without have to introduce an if statement for every variable.

Any help will be appreciated.

Megan

推荐答案




这篇关于Access Query中的全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 12:49