问题描述
我使用以下代码(在FE上的命令按钮后面)将用户的本地BE副本重新链接到LAN上的文件服务器的BE 。
我使用这个,例如,当一个人带上他们的笔记本电脑并且
连接到我们的局域网时。
如果当时没有其他用户访问服务器
BE,代码工作正常。但是,如果文件服务器的BE当时是打开的,那么,
然后重新链接过程没有完成 - 它只是暂停。当
其他所有人都关闭了数据库,然后这个过程继续在它自己的
上,笔记本电脑的FE现在链接到服务器的BE。
我们的多用户分割数据库设置正常工作 -
同时用户可以打开和关闭数据库而无需
问题 - 只要他们的FE已经链接到服务器的BE。
另一个因素:FE有一个隐藏的形式,总是打开,哪个是基于BE中的实用工具表获得
。
问题:
有什么我可以做的,它将允许计算机在我们的局域网上
从本地BE重新连接到服务器的BE而没有其他人
关闭数据库?
感谢您的帮助。
Mark
Dim dbs作为数据库
Dim tdf As TableDef
Dim Tdfs As TableDefs
Dim NewPathname As String
设置dbs = C urrentDb
设置Tdfs = dbs.TableDefs
''****************链接到网络驱动器 - P $ />
如果Len(Dir(P:\ fpsdata.mdb))= 0那么
MsgBox"你没有连接到网络。
恢复退出处理程序
结束如果
NewPathname =" P:\ fpsdata.mdb"
''循环通过表格集合
每个tdf在Tdf中
错误GoTo errhandler
''...链接主表
如果Len(tdf.Connect)> 0然后
tdf.Connect =" ;; DATABASE =" &安培; NewPathname
tdf.RefreshLink
结束如果
下一步''转到下一张表
I use the following code (behind a command button on the FE) to relink
from a user''s local copy of the BE to the file-server''s BE on our LAN.
I use this, for example, when a person brings in their laptop and
connects to our LAN.
The code works fine if there are no other users accessing the server''s
BE at the time. If the file-server''s BE is open at the time, however,
then the relinking process does not finish -- it just pauses. When
everyone else closes out of the database, then the process continues on
its own and the laptop''s FE is now linked to the server''s BE.
Our multi-user, split database setup works fine normally --
simultaneous users can open and close out of the database without a
problem -- as long as their FEs are already linked to the server''s BE.
One other factor: The FEs have a hidden form, always open, and which is
based on a utility table in the BE.
Question:
Is there anything I can do which will allow computers on our LAN to
relink from a local BE to the server''s BE without having everyone else
close out of the database?
Thanks for any help.
Mark
Dim dbs As Database
Dim tdf As TableDef
Dim Tdfs As TableDefs
Dim NewPathname As String
Set dbs = CurrentDb
Set Tdfs = dbs.TableDefs
''****************Link to Network Drive-P
If Len(Dir("P:\fpsdata.mdb")) = 0 Then
MsgBox "You''re not connected to the network."
Resume exithandler
End If
NewPathname = "P:\fpsdata.mdb"
''Loop through the tables collection
For Each tdf In Tdfs
On Error GoTo errhandler
''...link main tables
If Len(tdf.Connect) > 0 Then
tdf.Connect = ";DATABASE=" & NewPathname
tdf.RefreshLink
End If
Next ''Goto next table
推荐答案
这似乎没有非常正确 - 您应该可以重新链接,而其他人
连接到BE。如果您将表重新链接到
后端,然后允许其他人重新登录,以便您正常连接,会发生什么。在这一点
,单击按钮并重新链接(无论你是否已经正确连接了
,代码应该仍然做同样的事情) 。
这项工作,还是挂起?
你没有解释的是当你尝试重新链接时。如果你有一个
隐藏的表格连接到后端并且应该总是加载,那么如果前端表不能正常工作则无法打开。也许
这是挂起的原因。如果没有,请回复。
This doesn''t seem quite right - you should be able to re-link while others
are connected to the BE. What happens if you re-link your tables to the
back end, then allow others back in so you are all connected normally. At
this point, click the button and re-link (it doesn''t matter that you were
already correctly connected, the code should still do the same thing). Does
this work, or does it hang?
What you have not explained is when you try and re-link. If you have a
hidden form which is connected to the back end and is supposed to be always
loaded, this cannot open if your front end tables are not working. Perhaps
this is the cause of the hang. If not, post back.
您无法重新挂接已打开的表。在重新附加之前,使用
打开表关闭所有表单和进程。您还应该在重新附加表格后关闭并重新打开FE
数据库。
You cannot reattach a table that is open. Close all forms and processes with
open tables before reattaching. You should also close and reopen the FE
database after reattaching the tables.
这篇关于重新解决问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!