giovanniroi
Registered User.
- Local time
- Today, 02:01
- Joined
- Oct 23, 2010
- Messages
- 26
Threre support,
I use this code to upgrade the Access Backend data base but I have the problem to test the DROP execution of the table in the Backend before copy the new table.
I insert a time pause to be sure that DROP command are executed but this is a critical issue because I am not sure that this time is suffcient to make the DROP.
How can I Test the DROP Command execution before copy the new table?
Thank' for the support
Giovanni Roi
======================
Function Update_backend_DB()
Dim NewTableName As String
Dim OldTableName As String
Dim PauseTime As Integer
Dim Start As Date
Dim cnn As ADODB.Connection
Dim Connessione As String
Dim rstD As New ADODB.Recordset
Set RsC = New ADODB.Recordset
NewTableName = "TA03_Compagnie_SEL"
OldTableName = "TA03_Compagnie"
' make the backend table list
& " FROM MSysObjects IN 'C:\TMP\Backend_be.accdb'" _
& " WHERE (((MSysObjects.Type)=6 Or (MSysObjects.Type)=1));"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
'verify that the OLD table are available in the backend
strSQL = " SELECT MyTabelList_CTR.*" _
& " FROM MyTabelList_CTR" _
& " WHERE (((MyTabelList_CTR.Name)='" & OldTableName & "'));"
RsC.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If RsC.EOF = True Then
RsC.Close
GoTo L4
End If
RsC.Close
'delete OLD Table from the backend
Set cnn = New ADODB.Connection
Connessione = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\TMP\Backend_be.accdb;Persist Security Info=False"
cnn.Open Connessione
rstD.Open "DROP TABLE [" & OldTableName & "];", cnn, _
adOpenKeyset, adLockOptimistic
cnn.Close
Set cnn = Nothing
Set rstD = Nothing
PauseTime = 6 ' Imposta la durata.
Start = Timer ' Imposta l'ora di inizio.
Do While Timer < Start + PauseTime
DoEvents ' Passa il controllo ad altri processi.
Loop
'copy the new table in the backend
DoCmd.CopyObject "C:\TMP\Backend_be.accdb", OldTableName, acTable, NewTableName
'delete new table from the front end
DoCmd.DeleteObject acTable, NewTableName
L4: rsCTR.Close
Set rsCTR = Nothing
Set cnn = Nothing
Set rstD = Nothing
End Function
================
Giovanni Roi
I use this code to upgrade the Access Backend data base but I have the problem to test the DROP execution of the table in the Backend before copy the new table.
I insert a time pause to be sure that DROP command are executed but this is a critical issue because I am not sure that this time is suffcient to make the DROP.
How can I Test the DROP Command execution before copy the new table?
Thank' for the support
Giovanni Roi
======================
Function Update_backend_DB()
Dim NewTableName As String
Dim OldTableName As String
Dim PauseTime As Integer
Dim Start As Date
Dim cnn As ADODB.Connection
Dim Connessione As String
Dim rstD As New ADODB.Recordset
Set RsC = New ADODB.Recordset
NewTableName = "TA03_Compagnie_SEL"
OldTableName = "TA03_Compagnie"
' make the backend table list
& " FROM MSysObjects IN 'C:\TMP\Backend_be.accdb'" _
& " WHERE (((MSysObjects.Type)=6 Or (MSysObjects.Type)=1));"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
'verify that the OLD table are available in the backend
strSQL = " SELECT MyTabelList_CTR.*" _
& " FROM MyTabelList_CTR" _
& " WHERE (((MyTabelList_CTR.Name)='" & OldTableName & "'));"
RsC.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If RsC.EOF = True Then
RsC.Close
GoTo L4
End If
RsC.Close
'delete OLD Table from the backend
Set cnn = New ADODB.Connection
Connessione = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\TMP\Backend_be.accdb;Persist Security Info=False"
cnn.Open Connessione
rstD.Open "DROP TABLE [" & OldTableName & "];", cnn, _
adOpenKeyset, adLockOptimistic
cnn.Close
Set cnn = Nothing
Set rstD = Nothing
PauseTime = 6 ' Imposta la durata.
Start = Timer ' Imposta l'ora di inizio.
Do While Timer < Start + PauseTime
DoEvents ' Passa il controllo ad altri processi.
Loop
'copy the new table in the backend
DoCmd.CopyObject "C:\TMP\Backend_be.accdb", OldTableName, acTable, NewTableName
'delete new table from the front end
DoCmd.DeleteObject acTable, NewTableName
L4: rsCTR.Close
Set rsCTR = Nothing
Set cnn = Nothing
Set rstD = Nothing
End Function
================
Giovanni Roi