Right. I have finally got around to writing a module to automatically update a user's Front End each time the Database is opened - this was the best approach for me as new queries are requested on a regular basis.
When the Database is opened, an AutoExec macro is run, which runs an AutoExecCopy function borrowed from this site which I have played with. Here is the code for the function:-
So, in a nutshell, the code determines where the database is being run from, in my case it will always be from our K:\ drive as the users only have a shortcut for this one. As they are opening the FE from the K:\ drive, the code should then run the dbupdate.bat file, which copies the FE from the K:\ drive and pastes it over their local FE on their C:\ drive. I then had to put a delay in to ensure the copy was completed, before finally closing the FE from the K:\ drive and opening the updated FE from their C:\ drive.
I thought all was working well until I noticed that the FE from the K:\ drive was still active, instead of the updated FE on the C:\ drive. The update works fine, I can see that the changes have taken place by opening the C:\ drive version through Windows Explorer, but the code doesn't appear to close the K:\ drive version and then open the C:\ drive version at the end.
I would be grateful if someone could help me out on this one, have spent hours!!!
When the Database is opened, an AutoExec macro is run, which runs an AutoExecCopy function borrowed from this site which I have played with. Here is the code for the function:-
Code:
Public Function AutoExecCopy()
' If the current instance of the database is not being run
' from the local drive, delete the local copy and copy the
' front-end file stored on the server;
If Left(CurrentDb.Name, 3) <> "C:\" Then
If KillFile(fePath) = True Then
Shell "cmd /k ""K:\Rapid\BST - general\Release Testing\Testing Database\dbupdate.bat""", vbNormalFocus
'Pause while new Front End is copied
Dim PauseTime, Start
PauseTime = 1000 ' Set your duration here.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
End If
Shell """" & SysCmd(acSysCmdAccessDir) _
& "msaccess.exe"" " & """" _
& fePath & """", vbMaximizedFocus
Application.Quit
End If
End Function
So, in a nutshell, the code determines where the database is being run from, in my case it will always be from our K:\ drive as the users only have a shortcut for this one. As they are opening the FE from the K:\ drive, the code should then run the dbupdate.bat file, which copies the FE from the K:\ drive and pastes it over their local FE on their C:\ drive. I then had to put a delay in to ensure the copy was completed, before finally closing the FE from the K:\ drive and opening the updated FE from their C:\ drive.
I thought all was working well until I noticed that the FE from the K:\ drive was still active, instead of the updated FE on the C:\ drive. The update works fine, I can see that the changes have taken place by opening the C:\ drive version through Windows Explorer, but the code doesn't appear to close the K:\ drive version and then open the C:\ drive version at the end.
I would be grateful if someone could help me out on this one, have spent hours!!!
Last edited: