在MS Access中引用公共变量 [英] Referencing a public variable in MS Access

查看:85
本文介绍了在MS Access中引用公共变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试引用我在表单模块中声明的公共变量,但是调用它的用户模块无法识别它。我已经有几年没用过VBA了,忘记了怎么做! MS帮助文件告诉如何声明公共变量,但不知道如何引用它。声明是[Public strCurrentUser as String]。谁能提醒我如何引用它,好吗?谢谢。

I''m trying to reference a public variable that I have declared in a form module but the user module that is calling it doesn''t recognise it. I haven''t used VBA for some years and have forgotten how to do it! The MS help file tells how to declare a public variable but not how to reference it. The declaration is [Public strCurrentUser as String]. Can anyone remind me how to reference it, please? Thanks.

推荐答案

没有引用公共变量的技巧,只需按名称简单引用它。但是如果你在表单中声明它是公开的,那么当某个模块使用公共变量时,表单必须是打开的。


你说调用它的用户模块没有不认识它。

我不明白。引用变量的子或函数是由定义公共变量的形式中的某些代码调用的吗?
There is no trick to referencing a public variable, simple reference it by name. But if you declared it public in a form then the form must be open when the public variable is used by some module.

You say "the user module that is calling it doesn''t recognise it."
I don''t understand that. Is the sub or function referencing the variable being called by some code in the form where the public variable is defined?


包含声明Sue是很好的。它也有助于包括你引用它的尝试,特别注意它是来自VBA还是SQL。
It''s great that you included the declaration Sue. It would also help to include your attempt to reference it, with particular attention to whether that''s from VBA or SQL.


技巧是知道表格也必须被引用。我在VBA中使用了一个SQL语句。感谢您的回复:我实际上直接从我帖子下方弹出的有用项目中得到答案。
The trick was knowing the form had to be referenced as well. and I was using a SQL statement within VBA. Thanks for the responses: I actually got the answer straight away from the useful items that popped up below my post.


这篇关于在MS Access中引用公共变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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