mitchell1613
New member
- Local time
- Yesterday, 21:36
- Joined
- Jul 14, 2014
- Messages
- 4
I am using Access 2010 in a split database. The intent is to place the back end and associated linked files on a server and the front end on work stations for each user. The typical user will just be searching for information in the database not altering it. My current code re-links the tables once the path is known i.e. I have to hard code it into the global constant. Is there a way in VBA or utilizing VBA to read/write to an ini file (for example) that the UNC path would automatically be updated to a global constant in my current code that can be updated automatically based on where the back end is installed.:banghead:
Global Const BE_DATABASE = "\\192.168.2.3\FMC\ENFMCTABLES.accdb"
Global Const BE_PASSWORD = "***********"
Global Const BE_DATABASEPATH = "\\192.168.2.3\FMC\" 'used to open files
Public Sub CreateDatabaseLinks()
For Each td In db.TableDefs
Global Const BE_DATABASE = "\\192.168.2.3\FMC\ENFMCTABLES.accdb"
Global Const BE_PASSWORD = "***********"
Global Const BE_DATABASEPATH = "\\192.168.2.3\FMC\" 'used to open files
Public Sub CreateDatabaseLinks()
On Error Resume Next 'new
Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim td2 As DAO.TableDef 'new
Dim Attrib As Long
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(BE_DATABASE, False, False, _
Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim td2 As DAO.TableDef 'new
Dim Attrib As Long
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(BE_DATABASE, False, False, _
"MS Access;PWD=" & BE_PASSWORD)
Attrib = (td.Attributes And dbSystemObject)
If Attrib = 0 Then ' not a system table
If Attrib = 0 Then ' not a system table
Set td2 = CurrentDb.CreateTableDef(td.Name) 'new block
td2.SourceTableName = td.Name
td2.Connect = ";DATABASE=" & BE_DATABASE
CurrentDb.TableDefs.Append td2
td2.SourceTableName = td.Name
td2.Connect = ";DATABASE=" & BE_DATABASE
CurrentDb.TableDefs.Append td2
End If
Next
db.Close
ws.Close
Set db = Nothing
Set ws = Nothing
Set td = Nothing
End Subws.Close
Set db = Nothing
Set ws = Nothing
Set td = Nothing