全局变量失去价值没有明显的原因 [英] Global variable losing value for no apparent reason

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

问题描述

很奇怪。


我已经接管了遗留应用程序的责任,Access 2k3,

拆分FE / BE。

客户报告了一个问题,我正在调查。我没有写b

$ b AutoExec宏调用函数InitApplication反过来,

调用一个函数来设置全局字符串变量的值

" MyStrVar" (是的,我知道,全局......)


主窗体有一个退出按钮,它检查此

全局变量的值并根据值执行操作。

但是,代码中此时的断点显示

变量是空的(因此问题)。


经过大量的反复试验后,我发现了什么是

发生了,但不是为什么!以下循序渐进指南显示了我找到了什么
(我添加了MsgBox或断点以允许我

弄清楚什么''继续)。


1.首次自动执行 - MyStrVar是空的

2.调用函数加载变量 - MyStrVar正确加载

3.调用函数退出应用程序 - MyStrVar空 - 问题

4.申请退出。


重复上述但略有变化


1. Autoexec这是第一次 - MyStrVar是空的

2.调用函数加载变量 - MyStrVar正确加载

3.调用函数退出应用程序 - MyStrVar空 - 问题

4.按代码窗口中的RESET按钮并关闭表格,方法是翻转到

设计模式 - " MyStrVar"仍然是空的

5.第二次运行Autoexec - MyStrVar是空的

6.调用函数加载变量 - MyStrVar正确加载

7.调用函数退出应用程序 - MyStrVar现在正确

加载 - 为什么?


程序中的任何一点都没有对MyStrVar进行分配。除了

在函数中加载值。我手动执行的操作只需要运行AutoExec宏,然后按下表单上的退出

按钮。所以我的问题是:


a)为什么它失败?设置它并调用

函数以退出之间的值?


b)如果按RESET并再次运行它,为什么会改变这种行为?


如果它可能有帮助,这里是相关代码:


''加载变量的函数

Public Sub GetAllQueries ()


Dim rcd作为DAO.Recordset


设置rcd = CurrentDb.OpenRecordset(" SELECT tblDatabaseQueries.QryID

FROM tblDatabaseQueries;")

如果rcd.RecordCount 0那么

带rcd

.MoveFirst



MyStrVar = MyStrVar& " * QUOT; &安培; !QryID& " *"

.MoveNext

循环时没有(rcd.EOF)

结束时

结束如果


结束子


''退出的功能

Private Sub CloseDatabase_Click()

Dim Ref作为参考

Dim bar As CommandBar

Dim Qry作为QueryDef


每个参考参考文献

如果Ref.Name =" Word"然后References.Remove参考

下一个参考

每个栏在Application.CommandBars

bar.Enabled = True

下一个栏目

调用subfrmManageDatabaseQueries_Enter


每个Qry在CurrentDb.QueryDefs

如果是InStr(MyStrVar," *" & Qry.Name&" *")0然后

CurrentDb.QueryDefs.Delete(Qry.Name)

结束如果

下一个Qry

DoCmd.DeleteObject acTable,tblEditedQueries

DoCmd.Quit

End Sub

Weird.

I have taken over responsibility for a legacy application, Access 2k3,
split FE/BE.

The client has reported a problem and I''m investigating. I didn''t
write the application.

The AutoExec macro calls a function "InitApplication" which, in turn,
calls a function to set the value of a global string variable
"MyStrVar" (yes, I know, globals....)

The main form has a "Quit" button, which examines the value of this
global variable and performs an operation depending on the value.
However, a breakpoint at this point in the code shows that the
variable is empty (hence the problem).

After a good deal of trial and error, I have found out what is
happening, but not why! The following step-by-step guide shows what
I''ve found (I''ve added either MsgBox or breakpoints to allow me to
figure out what''s going on).

1. Autoexec for the first time - "MyStrVar" is emptly
2. Call function to load variable - "MyStrVar" correctly loaded
3. Call function to quit application - "MyStrVar" empty - PROBLEM
4. Application quits.

Repeat the above but with slight variation

1. Autoexec for the first time - "MyStrVar" is emptly
2. Call function to load variable - "MyStrVar" correctly loaded
3. Call function to quit application - "MyStrVar" empty - PROBLEM
4. Press RESET button in code window and close form by flipping to
design mode - "MyStrVar" still empty
5. Run Autoexec for the second time - "MyStrVar" is empty
6. Call function to load variable - "MyStrVar" correctly loaded
7. Call function to quit application - "MyStrVar" now correctly
loaded - WHY?

At no point in the program is there an assignment to "MyStrVar" except
in the function to load the value. The operations that I''m performing
manually are simply to run the AutoExec macro, and pressing the "Quit"
button on the form. So my questions are:

a) Why is it "losing" the value between setting it and calling the
function to quit?

b) Why does this behaviour change if I press RESET and run it again?

In case it might help here is the relevant code:

'' Function to load the variable
Public Sub GetAllQueries()

Dim rcd As DAO.Recordset

Set rcd = CurrentDb.OpenRecordset("SELECT tblDatabaseQueries.QryID
FROM tblDatabaseQueries;")
If rcd.RecordCount 0 Then
With rcd
.MoveFirst
Do
MyStrVar = MyStrVar & "*" & !QryID & "*"
.MoveNext
Loop While Not (rcd.EOF)
End With
End If

End Sub

''Function to quit
Private Sub CloseDatabase_Click()
Dim Ref As Reference
Dim bar As CommandBar
Dim Qry As QueryDef

For Each Ref In References
If Ref.Name = "Word" Then References.Remove Ref
Next Ref
For Each bar In Application.CommandBars
bar.Enabled = True
Next bar
Call subfrmManageDatabaseQueries_Enter

For Each Qry In CurrentDb.QueryDefs
If InStr(MyStrVar , "*" & Qry.Name & "*") 0 Then
CurrentDb.QueryDefs.Delete (Qry.Name)
End If
Next Qry
DoCmd.DeleteObject acTable, "tblEditedQueries"
DoCmd.Quit
End Sub

推荐答案

最重要的是你已经得到了一个Access bug。


也许如果你没有选择使用预期的DAL;然后也许你

会有更多的成功。

转移到ADO ..''事情就在那里工作'。


-Aaron

7月28日,5:30 * am,teddysn ... @ hotmail.com写道:
bottom line is that you''ve gotten bit by an Access bug.

Maybe if you weren''t choosing to use a depecrated DAL; then maybe you
would have more success.
Move to ADO.. ''things just work'' there.

-Aaron
On Jul 28, 5:30*am, teddysn...@hotmail.com wrote:

怪异。


我已经接管了遗留应用程序的责任,Access 2k3,

拆分FE / BE。


客户端报告了一个问题,我正在调查。 *我没有
写这个应用程序。


AutoExec宏调用一个函数InitApplication反过来,

调用一个函数来设置全局字符串变量的值

" MyStrVar" (是的,我知道,全局......)


主窗体有一个退出按钮,它检查此

全局变量的值并根据值执行操作。

但是,代码中此时的断点显示

变量是空的(因此问题)。


经过大量的反复试验后,我发现了什么是

发生了,但不是为什么! *以下分步指南显示了我找到了什么
(我添加了MsgBox或断点以允许我

弄清楚什么'正在进行中。


1. *第一次自动执行 - MyStrVar是空的

2. *调用函数加载变量 - MyStrVar正确加载

3. *调用函数退出应用程序 - *MyStrVar空 - 问题

4. *申请退出。


重复以上但略有变化


1。 *第一次Autoexec - MyStrVar是空的

2. *调用函数加载变量 - MyStrVar正确加载

3. *调用函数退出应用程序 - *MyStrVar空 - 问题

4. *按代码窗口中的RESET按钮并关闭表格,方法是翻转到

设计模式 - " MyStrVar"仍然是空的

5. *第二次运行Autoexec - MyStrVar是空的

6. *调用加载变量的函数 - MyStrVar正确加载

7. *调用函数退出应用程序 - *MyStrVar现在正确

加载 - 为什么?


程序中的任何一点都没有对MyStrVar进行分配。除了

在函数中加载值。 *我手动执行的操作只需要运行AutoExec宏,然后按下表单上的退出

按钮。所以我的问题是:


a)为什么它失败?设置它并调用

函数以退出之间的值?


b)如果按RESET并再次运行它,为什么会改变这种行为?


如果它可能有帮助,这里是相关代码:


''加载变量的函数

Public Sub GetAllQueries ()


* * Dim rcd作为DAO.Recordset


* *设置rcd = CurrentDb.OpenRecordset(" SELECT tblDatabaseQueries.QryID

FROM tblDatabaseQueries;")

* *如果rcd.RecordCount 0那么

* * * *带rcd

* * * * * * .MoveFirst

* * * * * *请

* * * * * * * * MyStrVar = MyStrVar& " * QUOT; &安培; !QryID& " *"

* * * * * * * * .MoveNext

* * * * * * * *循环而非(rcd.EOF)

* * * *结束时

* *结束如果


结束次级


' '功能退出

私人Sub CloseDatabase_Click()

昏暗参考作为参考

Dim bar As CommandBar

Dim Qry As QueryDef


每个参考参考资料

* *如果Ref.Name =" Word"然后References.Remove参考

* *下一个参考

每个酒吧在Application.CommandBars

* * bar.Enabled = True
* *下一栏

调用subfrmManageDatabaseQueries_Enter


每个Qry在CurrentDb.QueryDefs

* *如果是InStr (MyStrVar," *"& Qry.Name&" *")0然后

* * * * CurrentDb.QueryDefs.Delete(Qry.Name)

* *结束如果

下一个Qry

DoCmd.DeleteObject acTable," tblEditedQueries"

DoCmd.Quit

结束Sub
Weird.

I have taken over responsibility for a legacy application, Access 2k3,
split FE/BE.

The client has reported a problem and I''m investigating. *I didn''t
write the application.

The AutoExec macro calls a function "InitApplication" which, in turn,
calls a function to set the value of a global string variable
"MyStrVar" (yes, I know, globals....)

The main form has a "Quit" button, which examines the value of this
global variable and performs an operation depending on the value.
However, a breakpoint at this point in the code shows that the
variable is empty (hence the problem).

After a good deal of trial and error, I have found out what is
happening, but not why! *The following step-by-step guide shows what
I''ve found (I''ve added either MsgBox or breakpoints to allow me to
figure out what''s going on).

1. *Autoexec for the first time - "MyStrVar" is emptly
2. *Call function to load variable - "MyStrVar" correctly loaded
3. *Call function to quit application - *"MyStrVar" empty - PROBLEM
4. *Application quits.

Repeat the above but with slight variation

1. *Autoexec for the first time - "MyStrVar" is emptly
2. *Call function to load variable - "MyStrVar" correctly loaded
3. *Call function to quit application - *"MyStrVar" empty - PROBLEM
4. *Press RESET button in code window and close form by flipping to
design mode - "MyStrVar" still empty
5. *Run Autoexec for the second time - "MyStrVar" is empty
6. *Call function to load variable - "MyStrVar" correctly loaded
7. *Call function to quit application - *"MyStrVar" now correctly
loaded - WHY?

At no point in the program is there an assignment to "MyStrVar" except
in the function to load the value. *The operations that I''m performing
manually are simply to run the AutoExec macro, and pressing the "Quit"
button on the form. So my questions are:

a) Why is it "losing" the value between setting it and calling the
function to quit?

b) Why does this behaviour change if I press RESET and run it again?

In case it might help here is the relevant code:

'' Function to load the variable
Public Sub GetAllQueries()

* * Dim rcd As DAO.Recordset

* * Set rcd = CurrentDb.OpenRecordset("SELECT tblDatabaseQueries.QryID
FROM tblDatabaseQueries;")
* * If rcd.RecordCount 0 Then
* * * * With rcd
* * * * * * .MoveFirst
* * * * * * Do
* * * * * * * * MyStrVar = MyStrVar & "*" & !QryID & "*"
* * * * * * * * .MoveNext
* * * * * * * * Loop While Not (rcd.EOF)
* * * * End With
* * End If

End Sub

''Function to quit
Private Sub CloseDatabase_Click()
Dim Ref As Reference
Dim bar As CommandBar
Dim Qry As QueryDef

For Each Ref In References
* * If Ref.Name = "Word" Then References.Remove Ref
* * Next Ref
For Each bar In Application.CommandBars
* * bar.Enabled = True
* * Next bar
Call subfrmManageDatabaseQueries_Enter

For Each Qry In CurrentDb.QueryDefs
* * If InStr(MyStrVar , "*" & Qry.Name & "*") 0 Then
* * * * CurrentDb.QueryDefs.Delete (Qry.Name)
* * End If
Next Qry
DoCmd.DeleteObject acTable, "tblEditedQueries"
DoCmd.Quit
End Sub


哦小女孩Aaron - 你不是一个男人可以弄清楚如何系你的

鞋。


" aaron _ kemp f" < aa ********* @ hotmail.comwrote in message

news:fe ********************* ************* @ k36g2000 pri.googlegroups.com ...

底线是你已经得到了一个Access bug。


也许如果你没有选择使用特定的DAL;然后也许你

会有更多的成功。

转移到ADO ..''事情就在那里工作'。


-Aaron

7月28日早上5:30,teddysn ... @ hotmail.com写道:
Oh little girl Aaron - you aren''t man enough to figure out how to tie your
shoes.

"a a r o n _ k e m p f" <aa*********@hotmail.comwrote in message
news:fe**********************************@k36g2000 pri.googlegroups.com...
bottom line is that you''ve gotten bit by an Access bug.

Maybe if you weren''t choosing to use a depecrated DAL; then maybe you
would have more success.
Move to ADO.. ''things just work'' there.

-Aaron
On Jul 28, 5:30 am, teddysn...@hotmail.com wrote:

奇怪。


我已经接管了遗留应用程序的责任,Access 2k3,

拆分FE / BE。


客户端有报告了一个问题,我正在调查。我没有写b

$ b AutoExec宏调用函数InitApplication反过来,

调用一个函数来设置全局字符串变量的值

" MyStrVar" (是的,我知道,全局......)


主窗体有一个退出按钮,它检查此

全局变量的值并根据值执行操作。

但是,代码中此时的断点显示

变量是空的(因此问题)。


经过大量的反复试验后,我发现了什么是

发生了,但不是为什么!以下循序渐进指南显示了我找到了什么
(我添加了MsgBox或断点以允许我

弄清楚什么''继续)。


1.首次自动执行 - MyStrVar是空的

2.调用函数加载变量 - MyStrVar正确加载

3.调用函数退出应用程序 - MyStrVar空 - 问题

4.申请退出。


重复上述但略有变化


1. Autoexec这是第一次 - MyStrVar是空的

2.调用函数加载变量 - MyStrVar正确加载

3.调用函数退出应用程序 - MyStrVar空 - 问题

4.按代码窗口中的RESET按钮并关闭表格,方法是翻转到

设计模式 - " MyStrVar"仍然是空的

5.第二次运行Autoexec - MyStrVar是空的

6.调用函数加载变量 - MyStrVar正确加载

7.调用函数退出应用程序 - MyStrVar现在正确

加载 - 为什么?


程序中的任何一点都没有对MyStrVar进行分配。除了

在函数中加载值。我手动执行的操作只需要运行AutoExec宏,然后按下表单上的退出

按钮。所以我的问题是:


a)为什么它失败?设置它并调用

函数以退出之间的值?


b)如果按RESET并再次运行它,为什么会改变这种行为?


如果它可能有帮助,这里是相关代码:


''加载变量的函数

Public Sub GetAllQueries ()


Dim rcd作为DAO.Recordset


设置rcd = CurrentDb.OpenRecordset(" SELECT tblDatabaseQueries.QryID

FROM tblDatabaseQueries;")

如果rcd.RecordCount 0那么

带rcd

.MoveFirst



MyStrVar = MyStrVar& " * QUOT; &安培; !QryID& " *"

.MoveNext

循环时没有(rcd.EOF)

结束时

结束如果


结束子


''退出的功能

Private Sub CloseDatabase_Click()

Dim Ref作为参考

Dim bar As CommandBar

Dim Qry作为QueryDef


每个参考参考文献

如果Ref.Name =" Word"然后References.Remove参考

下一个参考

每个栏在Application.CommandBars

bar.Enabled = True

下一个栏目

调用subfrmManageDatabaseQueries_Enter


每个Qry在CurrentDb.QueryDefs

如果是InStr(MyStrVar," *" & Qry.Name&" *")0然后

CurrentDb.QueryDefs.Delete(Qry.Name)

结束如果

下一个Qry

DoCmd.DeleteObject acTable,tblEditedQueries

DoCmd.Quit

End Sub
Weird.

I have taken over responsibility for a legacy application, Access 2k3,
split FE/BE.

The client has reported a problem and I''m investigating. I didn''t
write the application.

The AutoExec macro calls a function "InitApplication" which, in turn,
calls a function to set the value of a global string variable
"MyStrVar" (yes, I know, globals....)

The main form has a "Quit" button, which examines the value of this
global variable and performs an operation depending on the value.
However, a breakpoint at this point in the code shows that the
variable is empty (hence the problem).

After a good deal of trial and error, I have found out what is
happening, but not why! The following step-by-step guide shows what
I''ve found (I''ve added either MsgBox or breakpoints to allow me to
figure out what''s going on).

1. Autoexec for the first time - "MyStrVar" is emptly
2. Call function to load variable - "MyStrVar" correctly loaded
3. Call function to quit application - "MyStrVar" empty - PROBLEM
4. Application quits.

Repeat the above but with slight variation

1. Autoexec for the first time - "MyStrVar" is emptly
2. Call function to load variable - "MyStrVar" correctly loaded
3. Call function to quit application - "MyStrVar" empty - PROBLEM
4. Press RESET button in code window and close form by flipping to
design mode - "MyStrVar" still empty
5. Run Autoexec for the second time - "MyStrVar" is empty
6. Call function to load variable - "MyStrVar" correctly loaded
7. Call function to quit application - "MyStrVar" now correctly
loaded - WHY?

At no point in the program is there an assignment to "MyStrVar" except
in the function to load the value. The operations that I''m performing
manually are simply to run the AutoExec macro, and pressing the "Quit"
button on the form. So my questions are:

a) Why is it "losing" the value between setting it and calling the
function to quit?

b) Why does this behaviour change if I press RESET and run it again?

In case it might help here is the relevant code:

'' Function to load the variable
Public Sub GetAllQueries()

Dim rcd As DAO.Recordset

Set rcd = CurrentDb.OpenRecordset("SELECT tblDatabaseQueries.QryID
FROM tblDatabaseQueries;")
If rcd.RecordCount 0 Then
With rcd
.MoveFirst
Do
MyStrVar = MyStrVar & "*" & !QryID & "*"
.MoveNext
Loop While Not (rcd.EOF)
End With
End If

End Sub

''Function to quit
Private Sub CloseDatabase_Click()
Dim Ref As Reference
Dim bar As CommandBar
Dim Qry As QueryDef

For Each Ref In References
If Ref.Name = "Word" Then References.Remove Ref
Next Ref
For Each bar In Application.CommandBars
bar.Enabled = True
Next bar
Call subfrmManageDatabaseQueries_Enter

For Each Qry In CurrentDb.QueryDefs
If InStr(MyStrVar , "*" & Qry.Name & "*") 0 Then
CurrentDb.QueryDefs.Delete (Qry.Name)
End If
Next Qry
DoCmd.DeleteObject acTable, "tblEditedQueries"
DoCmd.Quit
End Sub


te********@hotmail.com 写道:

很奇怪。


我已经接管了遗留应用程序的责任,Access 2k3,

拆分FE / BE。


客户报告了一个问题,我正在调查。我没有写b

$ b AutoExec宏调用函数InitApplication反过来,

调用一个函数来设置全局字符串变量的值

" MyStrVar" (是的,我知道,全局......)


主窗体有一个退出按钮,它检查此

全局变量的值并根据值执行操作。

但是,代码中此时的断点显示

变量是空的(因此问题)。


经过大量的反复试验后,我发现了什么是

发生了,但不是为什么!以下循序渐进指南显示了我找到了什么
(我添加了MsgBox或断点以允许我

弄清楚什么''继续)。


1.首次自动执行 - MyStrVar是空的

2.调用函数加载变量 - MyStrVar正确加载

3.调用函数退出应用程序 - MyStrVar空 - 问题

4.申请退出。


重复上述但略有变化


1. Autoexec这是第一次 - MyStrVar是空的

2.调用函数加载变量 - MyStrVar正确加载

3.调用函数退出应用程序 - MyStrVar空 - 问题

4.按代码窗口中的RESET按钮并关闭表格,方法是翻转到

设计模式 - " MyStrVar"仍然是空的

5.第二次运行Autoexec - MyStrVar是空的

6.调用函数加载变量 - MyStrVar正确加载

7.调用函数退出应用程序 - MyStrVar现在正确

加载 - 为什么?


程序中的任何一点都没有对MyStrVar进行分配。除了

在函数中加载值。我手动执行的操作只需要运行AutoExec宏,然后按下表单上的退出

按钮。所以我的问题是:


a)为什么它失败?设置它并调用

函数以退出之间的值?


b)如果按RESET并再次运行它,为什么会改变这种行为?


如果它可能有帮助,这里是相关代码:


''加载变量的函数

Public Sub GetAllQueries ()


Dim rcd作为DAO.Recordset


设置rcd = CurrentDb.OpenRecordset(" SELECT tblDatabaseQueries.QryID

FROM tblDatabaseQueries;")

如果rcd.RecordCount 0那么

带rcd

.MoveFirst



MyStrVar = MyStrVar& " * QUOT; &安培; !QryID& " *"

.MoveNext

循环时没有(rcd.EOF)

结束时

结束如果


结束子


''退出的功能

Private Sub CloseDatabase_Click()

Dim Ref作为参考

Dim bar As CommandBar

Dim Qry作为QueryDef


每个参考参考文献

如果Ref.Name =" Word"然后References.Remove参考

下一个参考

每个栏在Application.CommandBars

bar.Enabled = True

下一个栏目

调用subfrmManageDatabaseQueries_Enter


每个Qry在CurrentDb.QueryDefs

如果是InStr(MyStrVar," *" & Qry.Name&" *")0然后

CurrentDb.QueryDefs.Delete(Qry.Name)

结束如果

下一个Qry

DoCmd.DeleteObject acTable,tblEditedQueries

DoCmd.Quit

End Sub
Weird.

I have taken over responsibility for a legacy application, Access 2k3,
split FE/BE.

The client has reported a problem and I''m investigating. I didn''t
write the application.

The AutoExec macro calls a function "InitApplication" which, in turn,
calls a function to set the value of a global string variable
"MyStrVar" (yes, I know, globals....)

The main form has a "Quit" button, which examines the value of this
global variable and performs an operation depending on the value.
However, a breakpoint at this point in the code shows that the
variable is empty (hence the problem).

After a good deal of trial and error, I have found out what is
happening, but not why! The following step-by-step guide shows what
I''ve found (I''ve added either MsgBox or breakpoints to allow me to
figure out what''s going on).

1. Autoexec for the first time - "MyStrVar" is emptly
2. Call function to load variable - "MyStrVar" correctly loaded
3. Call function to quit application - "MyStrVar" empty - PROBLEM
4. Application quits.

Repeat the above but with slight variation

1. Autoexec for the first time - "MyStrVar" is emptly
2. Call function to load variable - "MyStrVar" correctly loaded
3. Call function to quit application - "MyStrVar" empty - PROBLEM
4. Press RESET button in code window and close form by flipping to
design mode - "MyStrVar" still empty
5. Run Autoexec for the second time - "MyStrVar" is empty
6. Call function to load variable - "MyStrVar" correctly loaded
7. Call function to quit application - "MyStrVar" now correctly
loaded - WHY?

At no point in the program is there an assignment to "MyStrVar" except
in the function to load the value. The operations that I''m performing
manually are simply to run the AutoExec macro, and pressing the "Quit"
button on the form. So my questions are:

a) Why is it "losing" the value between setting it and calling the
function to quit?

b) Why does this behaviour change if I press RESET and run it again?

In case it might help here is the relevant code:

'' Function to load the variable
Public Sub GetAllQueries()

Dim rcd As DAO.Recordset

Set rcd = CurrentDb.OpenRecordset("SELECT tblDatabaseQueries.QryID
FROM tblDatabaseQueries;")
If rcd.RecordCount 0 Then
With rcd
.MoveFirst
Do
MyStrVar = MyStrVar & "*" & !QryID & "*"
.MoveNext
Loop While Not (rcd.EOF)
End With
End If

End Sub

''Function to quit
Private Sub CloseDatabase_Click()
Dim Ref As Reference
Dim bar As CommandBar
Dim Qry As QueryDef

For Each Ref In References
If Ref.Name = "Word" Then References.Remove Ref
Next Ref
For Each bar In Application.CommandBars
bar.Enabled = True
Next bar
Call subfrmManageDatabaseQueries_Enter

For Each Qry In CurrentDb.QueryDefs
If InStr(MyStrVar , "*" & Qry.Name & "*") 0 Then
CurrentDb.QueryDefs.Delete (Qry.Name)
End If
Next Qry
DoCmd.DeleteObject acTable, "tblEditedQueries"
DoCmd.Quit
End Sub



如果某些东西不起作用,即使你没有写它,它也可能会让它变得有意义,所以它会改变它。


这是让它变得更好的绝佳时机。如果你有一个分开的

数据库,来自Tony Toew的网站和其他人的信息,建议

是你创建一个隐藏的形式,这是唯一的目的是在打开

应用程序时调用的前端和后端之间创建一个链接

。这有助于加快系统速度。


Docmd.Openform" PersistentLink" ,,,, acHidden


使用此表单,您可以创建一个文本框。当您运行autoexec时,

将字符串的值存储到文本框中。然后引用

文本框,而不是变量。


除非你有一个错误,否则不应该有全局问题

没有被困。但是因为你确实遇到了全局问题,所以改变你的方向。

If something doesn''t work, even if you didn''t write it, it might make
sense to change it so it does.

This would be an excellent time to make it better. If you have a split
database, from info at Tony Toew''s site and others, the recommendation
is that you create a hidden form that''s sole purpose is to create a link
between the front end and back end that is called when you open the
application. This can help speed up the system.

Docmd.Openform "PersistentLink",,,,acHidden

With this form you could create a textbox. When you run the autoexec,
store the value of the string to the textbox. Then reference the
textbox, not the variable.

There shouldn''t be a problem with globals unless you have an error that
is not trapped. But since you do have a problem with globals, change
your direction.


这篇关于全局变量失去价值没有明显的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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