Hello all,
Current Situation
Access (front end)
MSSQL (back end)
We have 2 environments, one test and one production
We develop in the test environment, and users work in the production environment..
All the tables in the Access are linked from the MSSQL database, and every time we bring the Access application to the other environment (so from test to production or vice versa) the tables are relinked. for this, we use the following code (this is pre-existing code written before i started working at the company)
Now the problem, when a new table is added in the test environment, and we copy the access application from the production to the test, it completely ignores this new table. This means that we have to add the table by hand. We work with several application all connected to the same database, and this is a time consuming job.
I want to know if it is possible to write some code that not only relinks all existing tables to the correct Environment, but also links the new tables found in the database.. I have tried working with the following code, but it seems that several tables are linked more then once, whilst others are not linked at all. I did comment out the second line in the previous piece of code to ensure that tables aren't linked twice
Does anyone have experience with this and do you guys have any suggestions.. If anything isn't clear, let me know, and i'll try to explain it with more detail
Current Situation
Access (front end)
MSSQL (back end)
We have 2 environments, one test and one production
We develop in the test environment, and users work in the production environment..
All the tables in the Access are linked from the MSSQL database, and every time we bring the Access application to the other environment (so from test to production or vice versa) the tables are relinked. for this, we use the following code (this is pre-existing code written before i started working at the company)
Code:
tCount = CurrentDb.TableDefs.Count - 1
For i = 0 To tCount
iPercent = i / tCount * 100
TableName = CurrentDb.TableDefs(1).Name
If Not TableName = "login" Then
If Left(TableName, 4) <> "msys" Then
'First delete the table from the list
DoCmd.DeleteObject acTable, TableName
'then add it again, in the correct environment
'PathEnv is the variable from which we get the Environment
DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;Driver={SQL Server};Server=SQLSERVER\SQLEXPRESS;Database=DB" & PathEnv & ";Trusted_Connection=Yes", acTable, "dbo." & TableName, TableName
End If
End If
Next
I want to know if it is possible to write some code that not only relinks all existing tables to the correct Environment, but also links the new tables found in the database.. I have tried working with the following code, but it seems that several tables are linked more then once, whilst others are not linked at all. I did comment out the second line in the previous piece of code to ensure that tables aren't linked twice
Code:
Set rs = ExecuteSqlQuery("SELECT * FROM sysobjects WHERE xtype='u' ORDER BY name ASC")
Do Until rs.EOF
DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;Driver={SQL Server};Server=SQLSERVER\SQLEXPRESS;Database=DB" & PathEnv & ";Trusted_Connection=Yes", acTable, "dbo." & rs.Fields("name"), rs.Fields("name")
rs.MoveNext
Loop
Comment