Help with auto update module (1 Viewer)

dbDamo

Registered User.
Local time
Today, 08:13
Joined
May 15, 2009
Messages
395
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:-

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:

apr pillai

AWF VIP
Local time
Today, 12:43
Joined
Jan 20, 2005
Messages
735
The delay loop is for about 17 minutes. Are you sure that you are checking the status after this time period? I don't know whether this will work but try changing Application.Quit to Docmd.Quit.
 

dbDamo

Registered User.
Local time
Today, 08:13
Joined
May 15, 2009
Messages
395
aprpillai - 1000 was a typo, was meant to be 10, which is why the K:\ drive FE version was still active and not the local copy, have amended the code (now to only 1 second) and works a treat, cheers!

RuralGuy - I had been following wiklendt's thread with interest but decided some time ago that I didn't want to create a new FE version every time I made changes, rather update the one on the K:\ drive as I would only be adding/removing queries. I've also done it this way as I will be leaving my company in the near future and wanted to ensure that it was as basic as possible so that my colleagues could continue to create queries without worrying about version control - they are not Access users and certainly not programmers, I've just shown them how to design a query and use the command button wizard to create a button to run the query.
 

RuralGuy

AWF VIP
Local time
Today, 01:13
Joined
Jul 2, 2005
Messages
13,825
That's fine. I just thought I'd check to make sure. You never know. Simple is good.
 

dbDamo

Registered User.
Local time
Today, 08:13
Joined
May 15, 2009
Messages
395
Thats fine, most people on here probably wouldn't have looked around. Simple is definitely good sometimes!
 

Users who are viewing this thread

Top Bottom