网站大量收购独家精品文档,联系QQ:2885784924

在access中如何自动备份.doc

  1. 1、本文档共6页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
在access中如何自动备份

前几天access数据库出现打不开了,说是数据损坏了,这样老让我提心吊胆的,所以我现在想设置个自动备份,不知道怎么设置,请哪位高手指点一下,谢谢!Public Sub BackupFile(Filename As String, Drive As String, Folder As String) Dim Fso As New FileSystemObject 创建 FSO 对象实例 Dim Dest_path As String, Counter As Long Dim StrDay As String, StrMonth As String, NewFilename As String Counter = 0 Do While Counter 6 如果驱动器没准备好,继续检测。共检测 6 秒 Counter = Counter + 1 Call Waitfor(1) 间隔 1 秒 If Fso.Drives(Drive).IsReady = True Then Exit Do End If Loop If Fso.Drives(Drive).IsReady = False Then 6 秒后目标盘仍未准备就绪,退出 MsgBox 目标驱动器 Drive 没有准备好! , vbCritical Exit Sub End If If Fso.GetDrive(Drive).FreeSpace Fso.GetFile(Filename).Size Then MsgBox 目标驱动器空间太小!, vbCritical 目标驱动器空间不够,退出 Exit Sub End If If Right(Drive, 1) : Then Drive = Drive : End If If Left(Folder, 1) \ Then Folder = \ Folder End If If Right(Folder, 1) \ Then Folder = Folder \ End If If Day(Date) 10 Then StrDay = 0 Day(Date) Else StrDay = Day(Date) End If If Month(Date) 10 Then StrMonth = 0 Month(Date) Else StrMonth = Month(Date) End If Fso.FileExists () NewFilename = newfilename Dest_path = Drive Folder If Not Fso.FolderExists(Dest_path) Then 如果目标文件夹不存在,创建之 Fso.CreateFolder Dest_path End If Fso.CopyFile Filename, Dest_path NewFilename, True 拷贝,直接覆盖同名文件 Set Fso = Nothing End Sub Private Sub Waitfor(Delay As Single) 延时过程,Delay 单位约为 1 秒 Dim StartTime As Single StartTime = Timer Do Until (Timer - StartTime) Delay Loop End Sub Private Sub Form_Load() BackupFile filename, d:, filebackupdir End End Sub 0 用VB编写自动备份文件程序? --------------------------------------? Public Sub BackupFile(Filename As String, Drive As String, Folder As String)? Dim Fso As New FileSystemObject 创建 FSO 对象实例? Dim Dest_path As String, Counter As Long? Dim StrDay As String, StrMonth As String, NewFilename As String? Counter = 0? Do While Counter 6 如果驱动器没准备好,继续检测。共检测 6 秒? Counter = Counter + 1? Call Waitfor(1) 间隔 1 秒? If Fso.Drives(Drive).IsReady = True Then? Exit Do? End If?

文档评论(0)

kakaxi + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档