第一步!先设置单位其中一台电脑作为服务器,建立一个共享文件夹,如“\\192.168.1.2\软件”,这里先用E:\软件
第二步,把自己的软件正在使用的软件命名为“软件1”,新软件命名为“软件”放在共享文件夹里面
第三步,软件启动窗口的加载加入代码实现以下功能
if CurrentProject.Name="软件2.mdb" then
Kill CurrentProject.Path & "\软件1.mdb"
If Dir("E:\软件\软件.mdb") <> "" Then
FileCopy "E:\软件\软件.mdb", CurrentProject.Path & "\软件1.mdb"
Application.FollowHyperlink CurrentProject.Path & "\软件1.mdb"
DoCmd.Quit
end if
End If
if CurrentProject.Name="软件1.mdb" then
Kill CurrentProject.Path & "\软件2.mdb"
If Dir("E:\软件\软件.mdb") <> "" Then
FileCopy "E:\软件\软件.mdb", CurrentProject.Path & "\软件2.mdb"
Application.FollowHyperlink CurrentProject.Path & "\软件2.mdb"
DoCmd.Quit
End If
End If
代码具体作用为。
1,先判断旧软件是否存在。存在就删除!
2,看看有无最新版关键,有就复制到当前文件夹。(这里最好设置一个字段去判断,用链接表到共享文件夹里面的数据库或sql数据库,判断数据库里面的版本号是否跟现在的版本号一致,一致则不下载)。
3,打开新软件,关闭当前软件,此时执行新软件的代码进行删除旧软件的操作
至此!更新完毕!大家试一试!