我已經在之前的數據庫中做過這些工作,並且進行了一些修改,我認爲您可以使其適合您的需求。
我將從檢查版本的角度開始,並發現它是否是最新版本或舊版本。
If Not updated Then
Select Case MsgBox("An update is available for your client!!!" _
+ " You would be able to use this client version but without new features and support!" _
+ " Do you want to update now?", vbYesNo Or vbInformation Or vbDefaultButton1, "Available Update")
Case vbYes
'Call MsgBox("Please contact your administrator to receive your new client version!!!", vbExclamation Or vbDefaultButton1, "Available Update")
Shell "cmd /c ""<whatever path you want>\doupdate.cmd"", vbHide" 'calls a cmd script to do the dirty job of copy -> see below
Application.CloseCurrentDatabase 'closes the current database
Exit Sub
Case vbNo
<whatever you want on no>
End Select
End If
您可以刪除上面的代碼的選擇,它會運行每次變量更新爲False而不詢問用戶。
的CMD腳本代碼如下:
@Echo OFF
SLEEP 3
copy "\\server\groups\<whatever path>\file.accde" "%userprofile%\Desktop\file.accde" /Y
call "%userprofile%\Desktop\file.accde"
exit
以上腳本當然不是完美的,因爲一個3秒忙等待的開始時,但我想,以確保訪問有時間關閉。 (問題會很大,如果acccess掛起關閉
你還可以做的是在數據庫的關閉事件上添加上面的命令或命令My.Computer.FileSystem.CopyFile()
,但是在這種情況下更新將發生在用戶已經完成了舊版本的工作
請注意,在那種情況下,我希望更新的腳本與數據庫分開,原因是其他原因,即使使用vba進行更新,主要原理也是一樣的,你必須在覆蓋之前關閉文件
爲什麼試圖隱藏有更新可用並將要安裝的事實? ible進程告訴用戶這將發生,關閉前端,安裝新版本並重新打開它。 – dbmitch