我在 Microsoft access vba 應用程式中遇到問題。我的專案包含 BE 和 FE 檔案,所以我想在打開前端時觸發客戶端在打開應用程式之前必須檢查更新,如果發現任何更新將下載到指定檔案夾。任何幫助??請
uj5u.com熱心網友回復:
由于我已經有代碼可以執行此操作,因此我將在此處發布它作為示例。
需要一個帶有單個記錄的表來保存當前的前端版本號,并且表單系結到該表,并帶有一個顯示版本欄位的文本框。表單上的標簽具有已發布前端的版本號。
在收到新計算機和 IT 安全設定阻止以編程方式復制檔案之前,這非常有效。我不得不修改代碼以簡單地通知用戶手動復制/替換檔案、打開檔案夾并中止打開資料庫檔案。
Private Sub Form_Load()
'Check for updates to the program on start up - if values don't match then there is a later version
If Me.tbxVersion <> Me.lblVersion.Caption Then
'because administrator opens the master development copy, only run this for non-administrator users
If DLookup("Permissions", "Users", "UserNetworkID='" & Environ("UserName") & "'") <> "admin" Then
'copy Access file
CreateObject("Scripting.FileSystemObject").CopyFile _
gstrBasePath & "Program\Install\MaterialsDatabase.accdb", "c:\", True
'allow enough time for file to completely copy before opening
Dim Start As Double
Start = Timer
While Timer < Start 3
DoEvents
Wend
'load new version - SysCmd function gets the Access executable file path
'Shell function requires literal quote marks in the target filename string argument, apostrophe delimiters fail, hence the quadrupled quote marks
Shell SysCmd(acSysCmdAccessDir) & "MSAccess.exe " & """" & CurrentProject.FullName & """", vbNormalFocus
'close current file
DoCmd.Quit
End If
Else
'tbxVersion available only to administrator to update version number in Updates table
Me.tbxVersion.Visible = False
Call UserLogin
End If
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/488981.html
上一篇:結果合并兩個具有獨立列的表
