we have a large MS Access application which uses SQL Server for the database (about 200 tables).
We want to convert it to a multi-tenancy database, where we will have a single large SQL Server database. Inside the database each client will have their own set of tables in their own schema. Eg, ten clients using database - ten Schemas in that database.
We will then migrate it to Azure and run the MS Access application as an Azure RemoteApp.
We want to create an Active Directory User Group for each client, and map it across to the default SQL Server Schema for that client.
The idea is that new users are added to the relevant AD User Group, and by default get mapped across to the right Schema with their data,
The problem we have is the MS Access Linked Tables contain a hard-coded explicit Schema (dbo by default).
Can anyone think of a way to store a "Source"/external/linked table in MS Access without having to specify a Schema. Eg. just "tblSales", not "dbo.tblSales".
A typical relink code goes like this (a snip only):
For Each tdf In dbs.TableDefs
strName = tdf.Name
If Asc(strName) <> Asc("~") Then
If InStr(tdf.Connect, cstrDbType) = 1 Then
tdf.Connect = strConnect
tdf.RefreshLink
Debug.Print Timer, tdf.Name, tdf.SourceTableName, tdf.Connect
DoEvents
End If
End If
Next
I have no other schema than dbo to test with, and I'm not sure if the property SourceTableName is read-only. If not, it could be adjusted:
For Each tdf In dbs.TableDefs
strName = tdf.Name
If Asc(strName) <> Asc("~") Then
If InStr(tdf.Connect, cstrDbType) = 1 Then
tdf.Connect = strConnect
tdf.SourceTableName = strNewSchema & "." & Split(tdf.SourceTableName, ".")(1)
tdf.RefreshLink
Debug.Print Timer, tdf.Name, tdf.SourceTableName, tdf.Connect
DoEvents
End If
End If
Next
If it is read-only, you will have to delete the linked table and recreate the link.
That said, I'm not sure if your idea of a schema for each client is such a good idea. We had similar considerations and decided simply to create a database for each client. If for nothing else, backup and restore clientwise is greatly simplified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.