Problem linking backend located on 2nd computer

  • Thread starter rdemyan via AccessMonster.com
  • Start date
R

rdemyan via AccessMonster.com

I have revoked all permissions on the backend files and am using RWOP queries.


All of a sudden I'm having troubl linking to my backend tables at startup.
I'm using the following
routine to accomplish the linking.

****************************************************************************************************************
Public Function RelinkToCurDir(PassedBEFile As String, FullPathProvided As
Boolean) As Boolean

On Error Resume Next

Dim wsBACK As DAO.Workspace
Dim dbBACK As DAO.Database
Dim BEFile As String

If FullPathProvided = False Then
BEFile = CurrentProject.Path & "\" & Mid([BackEndFileToCheck], InStrRev(
[BackEndFileToCheck], "\") + 1)
Else
BEFile = PassedBEFile
End If

'Open the backend db and set the current db

Set wsBACK = DBEngine.Workspaces(0)
Set dbBACK = wsBACK.OpenDatabase(BEFile)
Set db = CurrentDb()

'Now link the tables
For k = dbBACK.TableDefs.Count - 1 To 0 Step -1
TableToLink = dbBACK.TableDefs(k).Name
If dbBACK.TableDefs(k).Attributes <> -2147483648# And dbBACK.
TableDefs(k).Attributes <> 2# Then

'Delete the link if it already exists.
'Note if user tries to mistakingly connect to the front end
'then don't allow deletion of local table
If TableToLink <> "SysLinks" Then 'SysLinks is a front end
table
db.TableDefs.Delete TableToLink
End If

'Create the new link
Set tdf = db.CreateTableDef(TableToLink)

'Set the properties of the new link
'and append to the tabledefs collection
tdf.SourceTableName = TableToLink
tdf.Connect = ";DATABASE=" & BEFile
db.TableDefs.Append tdf
End If
Next k

RelinkToCurDir = True


Set db = Nothing
Set dbBACK = Nothing
Set tdf = Nothing

****************************************************************************************************************

By stepping through the code, I can find the error at:

For k = dbBACK.TableDefs.Count - 1 To 0 Step -1

The error is that the "Object variable or With Block variable is not set".
Because all permissons on the backend tables have been removed, MS says that
this procedure has to use On Error Resume Next.

If I go to Windows Explorer, I can easily see the 2nd computer on the home
network and I can drill down to the Back End file that I'm trying to link to.

What is causing this error to occur???

Thanks.



End Function
 
R

rdemyan via AccessMonster.com

Just a note. End Function is supposed to be at the end of the function but
instead is at the end of the post. I don't know how to edit my posts so I'm
mentioning this here.

I have revoked all permissions on the backend files and am using RWOP queries.

All of a sudden I'm having troubl linking to my backend tables at startup.
I'm using the following
routine to accomplish the linking.

****************************************************************************************************************
Public Function RelinkToCurDir(PassedBEFile As String, FullPathProvided As
Boolean) As Boolean

On Error Resume Next

Dim wsBACK As DAO.Workspace
Dim dbBACK As DAO.Database
Dim BEFile As String

If FullPathProvided = False Then
BEFile = CurrentProject.Path & "\" & Mid([BackEndFileToCheck], InStrRev(
[BackEndFileToCheck], "\") + 1)
Else
BEFile = PassedBEFile
End If

'Open the backend db and set the current db

Set wsBACK = DBEngine.Workspaces(0)
Set dbBACK = wsBACK.OpenDatabase(BEFile)
Set db = CurrentDb()

'Now link the tables
For k = dbBACK.TableDefs.Count - 1 To 0 Step -1
TableToLink = dbBACK.TableDefs(k).Name
If dbBACK.TableDefs(k).Attributes <> -2147483648# And dbBACK.
TableDefs(k).Attributes <> 2# Then

'Delete the link if it already exists.
'Note if user tries to mistakingly connect to the front end
'then don't allow deletion of local table
If TableToLink <> "SysLinks" Then 'SysLinks is a front end
table
db.TableDefs.Delete TableToLink
End If

'Create the new link
Set tdf = db.CreateTableDef(TableToLink)

'Set the properties of the new link
'and append to the tabledefs collection
tdf.SourceTableName = TableToLink
tdf.Connect = ";DATABASE=" & BEFile
db.TableDefs.Append tdf
End If
Next k

RelinkToCurDir = True

Set db = Nothing
Set dbBACK = Nothing
Set tdf = Nothing

****************************************************************************************************************

By stepping through the code, I can find the error at:

For k = dbBACK.TableDefs.Count - 1 To 0 Step -1

The error is that the "Object variable or With Block variable is not set".
Because all permissons on the backend tables have been removed, MS says that
this procedure has to use On Error Resume Next.

If I go to Windows Explorer, I can easily see the 2nd computer on the home
network and I can drill down to the Back End file that I'm trying to link to.

What is causing this error to occur???

Thanks.

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top