Mar 23 2012, 08:34 AM
My users seem to have a problem figuring out how to click on the 'upgrade' icon on their desktop. So I thought I would code in an auto upgrade.
My thought is to shell to another access file, have it copy the new version to their drive and the restart the new version.
I am stuck on the upgrade.mdb.
My code is...
FileCopy "t:repair tracker 2010.accdr", "c:\program files\repair tracker\repair tracker 2010.accdr"
Shell ("msaccess.exe c:\program files\repair tracker\repair tracker 2010.accdr")
It returns an error mentioning
'exit and restart access using valid command line options'
Note some of our machines have the full version of Office 2010 and some only have Runtime 2010.
Mar 23 2012, 08:42 AM
IF they are in the file and you try to shell out and copy a new file into the same place with the same name you will get an error as the file is open.
There are many many threads on this here in UA and you could search for auto updater.
to do it the way you are thinking you would need to use 2 files on the users computer. One to check for the latest version and copy/replace the other file if needed and then either way, open the other file and close itself
Mar 23 2012, 08:44 AM
Tony Toews autoupdater utility - works great!!
Mar 23 2012, 08:58 AM
This is the simplest and easy to use AutoFEUpdater.
Just follow the instruction.
I am sharing it because somebody shared it first.
Mar 23 2012, 09:15 AM
While these external programs look nice the first look to be more than I want.
The second gives the user options. I don't want any user options. These office zombies can barely spill their coffee let alone make a proper choice.
I know that I need to run an external (second) program to accomplish the total task.
I want my primary FE file to call a second 'upgrade' access file. This second access file will allow a time delay for the first to shut down before the copy begins. Then choose which version of access normal/runtime to fire up before shutting itself down.
My problem is I can't start another access db from within the first.
Mar 23 2012, 09:28 AM
These office zombies can barely spill their coffee let alone make a proper choice.
oh boy, youre too arrogant.
Mar 23 2012, 09:33 AM
It sounds like you want to use what I developed for my needs. Here is what you would need in some variation. Some way of telling if the local file is the right one or not. I do this by having a table on the BE called netversion and a local file on the FE called localversion. I have a simple small frontend FE that shows a form with a message saying, checking for the latest version please wait a moment. it determines if the localversion of the other file and the one on the server match. if they do they open the other file. Now, here comes the part you really want, when the other file opens it closes the first file. I also have it so the 2nd file cant be open on its own.
sound like what you are looking for ?
Mar 23 2012, 10:26 AM
As my login page opens on the FE it first checks it's internal version against a version table in the BE. I have had that for years. The problem comes after that.
I don't want my users to have to click on the current 'upgrade' icon.
I want to do away with that desktop icon.
I want access FE to open another access file (on server) and close itself. This second file will display 'upgrade in progress' and copy the new version of the FE file to the users drive and restart the new FE.
The copyfile part is easy and done.
I just can't get access to open the second access upgrade file. I can and do have it open PDFs and XLS and IEs. Just not access for some reason.
I could always use a .bat file but I want time delays and the possible need to choose between Office Access and Access Runtime.
Using a second acces .accdr I have secure code and splash screens for the users.
And yes I do have office zombies. They still insist on inserting contact names into email or password fields because they are at the top of the page and they don't want to page down.
Mar 23 2012, 10:40 AM
we have a slight disconnect. the NEW file has to close the first file. the users wouldnt have to click a thing other than to open the first file. why cant the "copy" come from the users computer and not from the server?
here s a clean snippet from what i use for an example. It may be missing a few things that I inadvertantly removed while cleaning it but the concept is there.
The first function will shell out and open the DB when called and then close the DB that called it.
the other piece is used to determine if an upgrade is necessary.
Option Compare Database
Public Function start()
On Error GoTo Err_Command1_Click
Dim stAppName As String
stAppName = Chr$(34) & (Left(CurrentDb.NAME, Len(CurrentDb.NAME) - Len(Dir(CurrentDb.NAME))) & "my.ACCDE" & Chr$(34))
Call Shell("msaccess.exe " & stAppName, 1)
Public Sub Form_Load()
On Error GoTo load_error
Dim rstlocalver As Recordset
Dim rstsystemver As Recordset
Dim vernumber As Integer
Dim rstauth As Recordset
Dim dst As Database
Dim strto As String
Dim strfrom As String
strpath = Left(CurrentDb.NAME, Len(CurrentDb.NAME) - Len(Dir(CurrentDb.NAME)))
If adhFileExists(Left(CurrentDb.NAME, Len(CurrentDb.NAME) - Len(Dir(CurrentDb.NAME))) & "\mousehook.dll") Then
strfrom = "\\serverpath\mousehook.dll"
strto = Left(CurrentDb.NAME, Len(CurrentDb.NAME) - Len(Dir(CurrentDb.NAME))) & "mousehook.dll"
FileCopy strfrom, strto
Set dst = OpenDatabase(Left(CurrentDb.NAME, Len(CurrentDb.NAME) - Len(Dir(CurrentDb.NAME))) & "my.ACCDE", False, False)
Set rstlocalver = dst.OpenRecordset("localversion")
Set rstsystemver = CurrentDb.OpenRecordset("version", dbOpenDynaset, dbSeeChanges)
If rstsystemver!vernumber <> rstlocalver!vernumber Then
veranswer = MsgBox("The current version is " & rstsystemver!vernumber & ". Your version is " & rstlocalver!vernumber & "." & Chr$(13) & "Failure to use the latest version may result in missing or wrong data. Please get the latest one." & Chr$(13) & "Would you like to get the latest one now?" & Chr$(13) & "If you choose No you will not be permitted to continue.", vbYesNo)
If veranswer = vbYes Then
strfrom = "\\servershare\my.ACCDE"
strto = Left(CurrentDb.NAME, Len(CurrentDb.NAME) - Len(Dir(CurrentDb.NAME))) & "my.ACCDE"
FileCopy strfrom, strto
MsgBox "You Do Not Have All The Files Necessary."
Mar 23 2012, 11:34 AM
Perfect ! Sort of.
I guess I needed the chr$(34). I changed your code to this.
Dim cur As String
cur = "c:\program files\repair tracker\repair tracker 2010.accdr"
Dim stAppName As String
stAppName = Chr$(34) & cur & Chr$(34)
Call Shell("msaccess.exe /runtime " & stAppName, 1)
But you are correct we did have a disconnect.
I wanted the main program to start the sub program and then terminate itself.
The sub program waits 3 to 5 seconds for the main to finish its termination then it starts the copy process.
It waits a few more seconds then restarts the (now new) main program. Then the sub program terminates itself.
I never intended for program A to control program B, that's above my rasin.
I wonder why I never have to use CHR$(34) when I shell to PDFs? Oh well.
Mar 23 2012, 11:44 AM
chr$(34) is the equivalent to the quote mark.
Personally, I go brain dead when trying to include quote marks inside quote marks to show that it is a string. so instead of this ""variable"" or '"variable"' i use chr(34) & variable & chr(34)
it is just personal preference.
are you good to go for now then ??
Mar 23 2012, 12:48 PM
Yes I am finishing the code now.
But then there is that stupid security warning when it starts. Arrrg!
But If I add the local directory to the trusted list that problem go's away.
If I could just add the server...... Nope it doesn't work for the server. I can live with putting the upgrade.mdb local.
Mar 23 2012, 01:45 PM
You can also add code to your FE so that, after it makes sure it's the current version, it looks to see if there's a copy of the updater.mdb on the local machine. If it's there, kill it.
That's what I do, to clean up after my update process.
Mar 23 2012, 02:35 PM
At least for now I'de rather have the updater.mdb on the local machine.
That way the user doesn't have to deal with the security warning box.
The code is working.
The FE opens and sees that it's out of date and fires the updater. Then the FE closes itself.
The updater copies the new FE file to the local drive and fires the new file. Then the updater closes itself.
All without user interaction.
Next I want to have it download the new file from a website. But that's down the road and around the bend.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here