Originally Posted by
Minty
I used to have an automatic FE script / VBS or bat file in house, and I had similar issues with renaming old versions, new versions not copying completely before trying to open etc etc.
I did eventually find some clever script that checked if the file could be not be opened somehow, and looped until it could then finished things off.
It's funny how looking at something fresh make you think about it - have just reordered my project list by most recently opened date at the top, no idea why I didn't do that before... Busman's holiday
Got it - about ten minutes to set it up, and it works great. Created a custom document variable to hold the date and time to nearest minute, as a text string, because the date format of custom document variables does not allow a time component. The following runs in the primary form's Open event:
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
If gbl_Uzivatel Like "*danes*" Then
If Format$(DateAdd("h", -1, Now), "YYYY-MM-DD HH:NN") > ReadCustomDocumentProperty("PosledniDevZaloha") Then
fs.CopyFile CurrentProject.Path & "\DataSavcu.accdb", CurrentProject.Path & "\DevZalohy\DataSavcuDevZaloha_" & Format$(Now(), "yyyy-mm-dd_hh-nn-ss") & ".accdb"
WriteCustomDocumentProperty "PosledniDevZaloha", Format$(Now, "YYYY-MM-DD HH:NN")
End If
End If
Created a special subfolder alongside the database and all development backups go in there. The code first checks to see if I am running it (so it won't do anything on the end user's machine). If it's me, it then looks to see if the last backup was more than an hour ago. If also yes, it makes a date/time stamped backup and updates the date/time of last backup in the custom document variable. For how much effort this took, and how much work it would have saved me, I'll have to buy myself a new pair of steel-toed boots to kick myself in the ass for not doing it long ago. This is going in everything I build from now on. Many thanks for the steer. If you ever make a trip to Prague, the beer is on me.