全局变量的麻烦 [英] Troubles with global variables

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

问题描述

我知道它可能被问了一百万次 - 但我似乎无法得到任何例子......


在Module1中我有一行:Global gvarMyEmpID As整数


然后我有一个开放的启动页面,用于登录过程,其中包含员工的下拉菜单和一个输入按钮


输入Button有一些代码包含....

gvarMyEmpID = Me!AgentID.Value

SQLtxt =" UPDATE [Version Control] SET [Version Control]。[Last代理人] =" &安培; gvarMyEmpID& ""

DoCmd.RunSQL SQLtxt


然后关闭Opening Splash页面然后出现菜单 - 带有一个文本框然而,当我在窗体视图中运行屏幕时,我得到的是控制源中的gvarMyEmpID是#Name?在盒子里。


如何在文本框中使用此变量,查询 - 在行源中,在其他页面上使用事件过程代码?

I know its probably been asked a million times - however I can''t seem to get any examples to work..

In Module1 I have a line: Global gvarMyEmpID As Integer

I then have an opening splash page for the logon process that has a drop down of the employees and an Enter Button

The Enter Button has some code that includes....
gvarMyEmpID = Me!AgentID.Value
SQLtxt = "UPDATE [Version Control] SET [Version Control].[Last Agent] = " & gvarMyEmpID & ";"
DoCmd.RunSQL SQLtxt

I then have the Opening Splash Page close and then the Menu appears - With a text box that has the gvarMyEmpID in the control source however all I get when I run the screen in Form View is "#Name?" in the box.

How can I use this variable in textboxes, Queries - in rowsources, and Event Procedure Code on other pages?

推荐答案


我知道它可能被问了一百万次 - 但是我似乎无法得到任何例子......


在Module1中我有一行:全局gvarMyEmpID作为整数


然后我有一个打开的启动页面,用于登录过程,其中包含员工下拉和输入按钮


Enter按钮有一些代码包含....

gvarMyEmpID = Me!AgentID.Value

SQLtxt =" UPDATE [Version控制] SET [版本控制]。[最后一个代理] =" &安培; gvarMyEmpID& ""

DoCmd.RunSQL SQLtxt


然后关闭Opening Splash页面然后出现菜单 - 带有一个文本框然而,当我在窗体视图中运行屏幕时,我得到的是控制源中的gvarMyEmpID是#Name?在盒子里。


如何在文本框,查询 - 行数源和其他页面上的事件过程代码中使用此变量?
I know its probably been asked a million times - however I can''t seem to get any examples to work..

In Module1 I have a line: Global gvarMyEmpID As Integer

I then have an opening splash page for the logon process that has a drop down of the employees and an Enter Button

The Enter Button has some code that includes....
gvarMyEmpID = Me!AgentID.Value
SQLtxt = "UPDATE [Version Control] SET [Version Control].[Last Agent] = " & gvarMyEmpID & ";"
DoCmd.RunSQL SQLtxt

I then have the Opening Splash Page close and then the Menu appears - With a text box that has the gvarMyEmpID in the control source however all I get when I run the screen in Form View is "#Name?" in the box.

How can I use this variable in textboxes, Queries - in rowsources, and Event Procedure Code on other pages?

  1. 关键字全局仅用于向后兼容 - 改为使用Public:
  1. The Keyword Global is only used for backward compatability - use Public instead:
展开 < span class =codeDivider> | 选择 | Wrap | Line数字


  1. 关键字全局仅用于向后兼容 - 改为使用Public:
  1. The Keyword Global is only used for backward compatability - use Public instead:
展开 | 选择 | Wrap | 行号



我试过,然后在菜单页面上输入以下On Load


我!Text22.value = gvarMyEmpID


我得到的只是一个0,当它应该是2 - bing工作人员的身份证我登录。


我必须以某种方式调用模块吗?
I tried that and then on the Menu page entered the following on the "On Load"

Me!Text22.value = gvarMyEmpID

And all i got was a 0 when it should have been a 2 - bing the ID of the staff member I logged in with.

Do I have to call the Module somehow??



RobH。


我试过一个例子,以下内容一切正常。


在公共模块Module1中

Hi, RobH.

I''ve tried an example and everything works fine with the following.

In public module "Module1"

展开 | 选择 | Wrap | 行号


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

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