使用recordsetclone时,Access实例保持打开状态。 [英] Instance of Access left open when using recordsetclone.

查看:131
本文介绍了使用recordsetclone时,Access实例保持打开状态。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,


我有以下代码:

''**************** ********************************* *****

如果不是我。 NewRecord然后


Dim rs As DAO.Recordset

Dim strBookmark As String

设置rs = Forms(" frmMaster") .RecordsetClone''设置表格实例

主记录集克隆

rs.FindFirstCustomerID =''" &安培; Me.CustomerID& "" ''在记录集中找到特定的

记录

如果不是rs.NoMatch那么

strBookmark = rs.Bookmark''抓住书签

表格(frmMaster)。书签= strBookmark''设置FORM等于

rs书签移动到该记录。

结束如果


结束如果

''************************ ************************* *******

此代码工作正常。

我使用此代码移动到主表单上的记录。我不能使用

其他技术,比如过滤,原因我不解释。


退出处理程序运行以下代码:

''*********************************************** ** *******

rs.Close

如果没有rs则什么都没有

设置rs = Nothing

结束如果

''********************************** *************** *******

此代码由主表单的SUBFORM的Current事件触发。

(换句话说,每次申请打开时)。


这是我的问题:


当应用程序退出锁定时前端和后端的文件

结尾不会自动删除。查看任务管理器(Win XP Pro)

显示Access的实例已打开。如果你回到

应用程序并尝试在设计视图中打开表单,你会得到你没有

有独家访问权限......错误信息。我之前从未见过这种行为

。有没有其他人。你能不能告诉我这里要做什么来摆脱这个问题。


塞思B斯皮尔曼

解决方案

哦 - 不要关闭记录集克隆,只需将其引用设置为Nothing。

一般规则是 - 如果你。打开它,然后。关闭它。如果你没有。打开它,

不要。关闭它。


周一,2004年3月1日22:34:41 - 0500,Seth Spearman, < se ********** @ hotmail.com>

写道:

嘿伙计们,
我有以下代码:
''************************************* *********** ******
如果不是Me.NewRecord然后

Dim rs As DAO.Recordset
Dim strBookmark As String <设置rs = Forms(frmMaster)。RecordsetClone''设置表格实例
主记录集克隆
rs.FindFirstCustomerID =''" &安培; Me.CustomerID& "" ''在记录集中找到一个特定的
记录
如果没有rs.NoMatch那么
strBookmark = rs.Bookmark''抓住书签
表格(frmMaster)。书签= strBookmark''设置FORM等于
rs书签移动到该记录。
结束如果

结束如果
''****** ****************************************** ********
此代码工作正常。
我使用此代码移动到我的主窗体上的记录。我不能使用其他技术,比如过滤,原因我不解释。

退出处理程序运行以下代码:
''********* *************************************** ******** rs.Close
如果没有rs则什么都没有
设置rs = Nothing
结束如果
''**************** ******************************** ********
此代码由主表格的SUBFORM的当前事件。
(换句话说,每次应用程序打开时)。

这是我的问题:

当应用程序退出时前端和后端的锁定文件不会自动删除。查看任务管理器(Win XP Pro)
显示Access的实例已打开。如果你回到
应用程序并试图在设计视图中打开表单,你会得到你没有独家访问权限......。错误信息。我之前从未见过这种行为。有没有其他人。你能告诉我这里要做什么来摆脱这个问题。

Seth B Spearman




Steve Jorgensen< no **** @ nospam.nospam>写在

新闻:79 ******************************** @ 4ax.com:

哦 - 不要关闭记录集克隆,只需将其引用设置为
Nothing。一般规则是 - 如果你。打开它,然后。关闭它。
如果你不打开它,不要。关闭它。




更好的是,不要使用记录集变量,而是使用WITH结构:


使用Forms!frmMaster.RecordsetClone

[做你的东西]

结束


然后你不必担心是否需要设置

什么都没有或者关闭你用过的东西。


-

David W. Fenton http://www.bway.net/~dfenton

dfenton at bway dot net http://www.bway.net/~dfassoc


< blockquote> On Tue,2004年3月2日22:54:18 GMT,David W. Fenton

< dX ******** @ bway.net.invalid>写道:

Steve Jorgensen< no **** @ nospam.nospam>在
新闻中写道:79 ******************************** @ 4ax.com:

哦 - 不要关闭记录集克隆,只需将其引用设置为
Nothing。一般规则是 - 如果你。打开它,然后。关闭它。
如果你不打开它,不要。关闭它。



更好的是,不要使用记录集变量,而是使用WITH结构:

使用Forms!frmMaster.RecordsetClone
[做你的事]
结束

然后你不必担心是否需要设置
Nothing或Close你使用过的东西。




好吧,你仍然需要担心是否。关闭它 - 不要:)如果.Close

是必需的,它需要在End With之前。我的第二个动议

,对于像这样的东西来说块是好的,只要避免长块或嵌套,因为它很难读。过程调用是一个很好的

替代嵌套使用块...


....

DoYourThing Forms!frmMaster。 RecordsetClone

....


Private Sub DoYourThing(rst as DAO.Recordset)

...

使用rst.Fields(Foo)''类型安全在With ...而不是rst!Foo

如果.Value> 500然后.Value = 500

结束

...

End Sub


Hey guys,

I have the following code:
''************************************************* *****
If Not Me.NewRecord Then

Dim rs As DAO.Recordset
Dim strBookmark As String
Set rs = Forms("frmMaster").RecordsetClone ''set an instance of form
master recordset clone
rs.FindFirst "CustomerID=''" & Me.CustomerID & "''" ''find a particular
record in the recordset
If Not rs.NoMatch Then
strBookmark = rs.Bookmark ''grab the bookmark
Forms("frmMaster").Bookmark = strBookmark ''set the FORM equal to
the rs bookmark to move to that record.
End If

End If
''************************************************* *******
This code works fine.
I am using this code to move to a record on my main form. I cannot use
another technique like filtering for reasons I will not explain.

The exit handler is running the following code:
''************************************************* *******
rs.Close
If Not rs Is Nothing Then
Set rs = Nothing
End If
''************************************************* *******
This code is triggered by the Current event of a SUBFORM of the Main form.
(in other words every time the application opens).

Here is my problem:

When the application exits the locking files for both the front end and back
ends are not automatically deleted. A look at Task Manager (Win XP Pro)
shows that an instance of Access is open. And if you go back into the
application and try to open the form in design view you get the "You do not
have exclusive access..." error message. I have never seen this behavior
before. Has anyone else. Can you clue me in on what to do here to rid
myself of this problem.

Seth B Spearman

解决方案

Oh - don''t close a recordset clone, just set its reference to Nothing. The
general rule is - If you .Open it, then .Close it. If you don''t .Open it,
don''t .Close it.

On Mon, 1 Mar 2004 22:34:41 -0500, "Seth Spearman" <se**********@hotmail.com>
wrote:

Hey guys,

I have the following code:
''************************************************ ******
If Not Me.NewRecord Then

Dim rs As DAO.Recordset
Dim strBookmark As String
Set rs = Forms("frmMaster").RecordsetClone ''set an instance of form
master recordset clone
rs.FindFirst "CustomerID=''" & Me.CustomerID & "''" ''find a particular
record in the recordset
If Not rs.NoMatch Then
strBookmark = rs.Bookmark ''grab the bookmark
Forms("frmMaster").Bookmark = strBookmark ''set the FORM equal to
the rs bookmark to move to that record.
End If

End If
''************************************************ ********
This code works fine.
I am using this code to move to a record on my main form. I cannot use
another technique like filtering for reasons I will not explain.

The exit handler is running the following code:
''************************************************ ********
rs.Close
If Not rs Is Nothing Then
Set rs = Nothing
End If
''************************************************ ********
This code is triggered by the Current event of a SUBFORM of the Main form.
(in other words every time the application opens).

Here is my problem:

When the application exits the locking files for both the front end and back
ends are not automatically deleted. A look at Task Manager (Win XP Pro)
shows that an instance of Access is open. And if you go back into the
application and try to open the form in design view you get the "You do not
have exclusive access..." error message. I have never seen this behavior
before. Has anyone else. Can you clue me in on what to do here to rid
myself of this problem.

Seth B Spearman




Steve Jorgensen <no****@nospam.nospam> wrote in
news:79********************************@4ax.com:

Oh - don''t close a recordset clone, just set its reference to
Nothing. The general rule is - If you .Open it, then .Close it.
If you don''t .Open it, don''t .Close it.



Better yet, don''t use a recordset variable, but a WITH structure:

With Forms!frmMaster.RecordsetClone
[do your thing]
End With

Then you don''t have to worry about whether you need to set to
Nothing or Close what you''ve used.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


On Tue, 02 Mar 2004 22:54:18 GMT, "David W. Fenton"
<dX********@bway.net.invalid> wrote:

Steve Jorgensen <no****@nospam.nospam> wrote in
news:79********************************@4ax.com :

Oh - don''t close a recordset clone, just set its reference to
Nothing. The general rule is - If you .Open it, then .Close it.
If you don''t .Open it, don''t .Close it.



Better yet, don''t use a recordset variable, but a WITH structure:

With Forms!frmMaster.RecordsetClone
[do your thing]
End With

Then you don''t have to worry about whether you need to set to
Nothing or Close what you''ve used.



Well, you still need to worry about whether to .Close it - don''t :) If .Close
was required, it would need to go before the End With. I second the motion
that With blocks are good for stuff like this, just avoid long block or
nesting because it gets really hard to read. Procedure calls are a good
alternative to nested With blocks...

....
DoYourThing Forms!frmMaster.RecordsetClone
....

Private Sub DoYourThing(rst As DAO.Recordset)
...
With rst.Fields("Foo") '' Is typesafe in With ... as opposed to rst!Foo
If .Value > 500 Then .Value = 500
End With
...
End Sub


这篇关于使用recordsetclone时,Access实例保持打开状态。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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