Hi,
I developed a database in Windows/Access2000 and split it into front end/ back end. In the front end I added some code that would check (on start up)if there was a more up to date version on the network using the following code:
Function UpdateVersion()
Dim strPath2AccessEXE As String
Dim strRun, strRunText As String
Dim strSourceDB As String, strTargetDB As String, strUpdaterDB As String
'copy latest MDE file on network to c drive and strRun locally if it is not the latest version
strRun = SysCmd(acSysCmdAccessVer)
strPath2AccessEXE = strRun & "\MSACCESS.EXE"
strSourceDB = "\\UPUD\Data\UPU-Docs\Production_fe\Production.mdb"
strTargetDB = "C:\Documents and Settings\" & Environ("username"
& "\Desktop\Production.mdb" 'my latest version on the network
strUpdaterDB = "\\UPUD\Data\UPU-Docs\Production_fe\Updater.mdb"
If FileDateTime(strTargetDB) < FileDateTime(strSourceDB) Then
strRunText = """" & strPath2AccessEXE & """ """ & strUpdaterDB
' Give the "Shell" command a window to operate
'Open a new instance of Access and pass it the command line variable.
Call Shell(strRunText, vbNormalFocus)
'Then close this instance of Access
Application.Quit
End If
End Function
As the code shows if there was a more up to date version it would close the current database and open another database called "Updater" that would actually do the copying. The "Updater" database would open a form on start up that would close after 10 seconds (to allow the Production database to fully close) and would run the following code on close:
Function UpdateInProgress()
Dim strSourceDB, strTargetDB, strDB1 As String
Dim strRun, strRunText, strPath2AccessEXE As String
Dim varResult As Variant
Dim oldName, newName As String
'copy latest MDE file on network to c drive and run locally if it is not the latest version
strSourceDB = "\\UPUD\Data\UPU-Docs\Production_fe\Production.mdb" 'my latest version on the network
strTargetDB = "C:\Documents and Settings\" & Environ("username"
& "\Desktop\Production.mdb" 'Current version on User's Desktop
oldName = strTargetDB
newName = "C:\Documents and Settings\" & Environ("username"
& "\Desktop\Production.BAK" 'Create Back up version
If FileDateTime(strTargetDB) < FileDateTime(strSourceDB) Then
'Rename of version
Name oldName As newName
DoEvents
'Copy newer Version
FileCopy strSourceDB, strTargetDB
DoEvents
'check if new version is there
If Len(Dir(strTargetDB)) > 0 Then
Kill newName 'if yes delete .bak file
Else
Name newName As oldName 'if no change .bak into .mdb again
End If
DoEvents
End If
'Delete any DB1 File
strDB1 = "C:\Documents and Settings\" & Environ("username"
& "\Desktop\DB1.MDB"
On Error Resume Next
Kill strDB1
'open the local MDB file
strRun = SysCmd(acSysCmdAccessVer)
strPath2AccessEXE = strRun & "\MSACCESS.EXE"
strRunText = """" & strPath2AccessEXE & """ """ & strTargetDB
' Give the "Shell" command a window to operate
'Open a new instance of Access and pass it the command line variable.
Call Shell(strRunText, vbNormalFocus)
'Then close this instance of Access
Application.Quit
End Function
This allowed any user of the database to have updates automatically copied from the network to their desktop and it worked brilliantly until the computers were updated to Windows XP and Office XP! Now the updater database opens as if it is copying the new version but it doesn't actually do it. If I open the Updater database on its own the code works properly but if the original Production.mdb opens it it won't work! Am very confused and would love to get it solved so that I don't have to keep going round to everyones PC manually to update the version on their desktops. I'd really appreciate any help anybody could give me.
Many thanks in advance,
G.P.M.
I developed a database in Windows/Access2000 and split it into front end/ back end. In the front end I added some code that would check (on start up)if there was a more up to date version on the network using the following code:
Function UpdateVersion()
Dim strPath2AccessEXE As String
Dim strRun, strRunText As String
Dim strSourceDB As String, strTargetDB As String, strUpdaterDB As String
'copy latest MDE file on network to c drive and strRun locally if it is not the latest version
strRun = SysCmd(acSysCmdAccessVer)
strPath2AccessEXE = strRun & "\MSACCESS.EXE"
strSourceDB = "\\UPUD\Data\UPU-Docs\Production_fe\Production.mdb"
strTargetDB = "C:\Documents and Settings\" & Environ("username"
strUpdaterDB = "\\UPUD\Data\UPU-Docs\Production_fe\Updater.mdb"
If FileDateTime(strTargetDB) < FileDateTime(strSourceDB) Then
strRunText = """" & strPath2AccessEXE & """ """ & strUpdaterDB
' Give the "Shell" command a window to operate
'Open a new instance of Access and pass it the command line variable.
Call Shell(strRunText, vbNormalFocus)
'Then close this instance of Access
Application.Quit
End If
End Function
As the code shows if there was a more up to date version it would close the current database and open another database called "Updater" that would actually do the copying. The "Updater" database would open a form on start up that would close after 10 seconds (to allow the Production database to fully close) and would run the following code on close:
Function UpdateInProgress()
Dim strSourceDB, strTargetDB, strDB1 As String
Dim strRun, strRunText, strPath2AccessEXE As String
Dim varResult As Variant
Dim oldName, newName As String
'copy latest MDE file on network to c drive and run locally if it is not the latest version
strSourceDB = "\\UPUD\Data\UPU-Docs\Production_fe\Production.mdb" 'my latest version on the network
strTargetDB = "C:\Documents and Settings\" & Environ("username"
oldName = strTargetDB
newName = "C:\Documents and Settings\" & Environ("username"
If FileDateTime(strTargetDB) < FileDateTime(strSourceDB) Then
'Rename of version
Name oldName As newName
DoEvents
'Copy newer Version
FileCopy strSourceDB, strTargetDB
DoEvents
'check if new version is there
If Len(Dir(strTargetDB)) > 0 Then
Kill newName 'if yes delete .bak file
Else
Name newName As oldName 'if no change .bak into .mdb again
End If
DoEvents
End If
'Delete any DB1 File
strDB1 = "C:\Documents and Settings\" & Environ("username"
On Error Resume Next
Kill strDB1
'open the local MDB file
strRun = SysCmd(acSysCmdAccessVer)
strPath2AccessEXE = strRun & "\MSACCESS.EXE"
strRunText = """" & strPath2AccessEXE & """ """ & strTargetDB
' Give the "Shell" command a window to operate
'Open a new instance of Access and pass it the command line variable.
Call Shell(strRunText, vbNormalFocus)
'Then close this instance of Access
Application.Quit
End Function
This allowed any user of the database to have updates automatically copied from the network to their desktop and it worked brilliantly until the computers were updated to Windows XP and Office XP! Now the updater database opens as if it is copying the new version but it doesn't actually do it. If I open the Updater database on its own the code works properly but if the original Production.mdb opens it it won't work! Am very confused and would love to get it solved so that I don't have to keep going round to everyones PC manually to update the version on their desktops. I'd really appreciate any help anybody could give me.
Many thanks in advance,
G.P.M.