C
Chris O''Neill
I'm developing a FE/BE database and I want to link to a different BE
depending on whether the person logging in is a registered user or is a "demo
user". The registered user will link to the "real" BE database and the "demo
user" will link to a database that contains dummy data and read-only
privileges. I have all the code for logging in the users, but can't get my
table relinking code to work. Here's the code (modified from the MS Access
Security FAQ) I'm using to connect to the distribution database. I have an
identical functions (ConnectLinkDEMO) for the "demo" database (with a
different filename of course).
'************* Begin Code ***************
Function ConnectLinkDIST()
On Error GoTo ERR_ConnectLink
' This function can be run by any user who has OpenRun permission
' on the source database. It works equally well to link tables
' from scratch or to relink previously attached tables. In-line
' error handling is used to ignore any errors
Dim db As Database
Dim tdf As TableDef
Dim tdfLoop As TableDef
Dim strTable As String
Set db = CurrentDb()
With db
For Each tdfLoop In .TableDefs
strTable = tdfLoop.Name
If Left$(strTable, 3) = "tbl" Then ' Don't mess with system
tables
' Delete the link if it already exists
db.TableDefs.Delete strTable
' Create new link
Set tdf = db.CreateTableDef(strTable)
' Set the properties of the new link
' and append to the tabledefs collection
tdf.SourceTableName = strTable
tdf.Connect = ";DATABASE=balloons_secured_DATA_DIST.mdb"
db.TableDefs.Append tdf
End If
Next tdfLoop
End With
Exit_ConnectLink:
Exit Function
End Function
'************* End Code *****************
When I run either of these functions, I'm still linked to the distribution
table. It doesn't matter if I do it as the db owner or a "demo user" nor
does it matter if I do it from the immediate window or within my application.
What am I missing here??? Any and all help will be greatly appreciated!
Regards, Chris
depending on whether the person logging in is a registered user or is a "demo
user". The registered user will link to the "real" BE database and the "demo
user" will link to a database that contains dummy data and read-only
privileges. I have all the code for logging in the users, but can't get my
table relinking code to work. Here's the code (modified from the MS Access
Security FAQ) I'm using to connect to the distribution database. I have an
identical functions (ConnectLinkDEMO) for the "demo" database (with a
different filename of course).
'************* Begin Code ***************
Function ConnectLinkDIST()
On Error GoTo ERR_ConnectLink
' This function can be run by any user who has OpenRun permission
' on the source database. It works equally well to link tables
' from scratch or to relink previously attached tables. In-line
' error handling is used to ignore any errors
Dim db As Database
Dim tdf As TableDef
Dim tdfLoop As TableDef
Dim strTable As String
Set db = CurrentDb()
With db
For Each tdfLoop In .TableDefs
strTable = tdfLoop.Name
If Left$(strTable, 3) = "tbl" Then ' Don't mess with system
tables
' Delete the link if it already exists
db.TableDefs.Delete strTable
' Create new link
Set tdf = db.CreateTableDef(strTable)
' Set the properties of the new link
' and append to the tabledefs collection
tdf.SourceTableName = strTable
tdf.Connect = ";DATABASE=balloons_secured_DATA_DIST.mdb"
db.TableDefs.Append tdf
End If
Next tdfLoop
End With
Exit_ConnectLink:
Exit Function
End Function
'************* End Code *****************
When I run either of these functions, I'm still linked to the distribution
table. It doesn't matter if I do it as the db owner or a "demo user" nor
does it matter if I do it from the immediate window or within my application.
What am I missing here??? Any and all help will be greatly appreciated!
Regards, Chris