设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

压缩、修复指定的数据库

1970-1-1 08:00| 发布者: Grant| 查看: 1097| 评论: 0

压缩、修复指定的数据库

Public Function RepairDatabase(strSource As String) As Boolean
    On Error GoTo error_handler
    Dim I As Integer
    '生成压缩后的文件名
    Dim strDestination As String
    I = 1
    Do
        strDestination = strSource & I
        If Dir(strSource & I) = "" Then
            Exit Do
        Else
            I = I + 1
        End If
    Loop
    '压缩修复指定文件
    RepairDatabase = _
        Application.CompactRepair( _
        LogFile:=True, _
        SourceFile:=strSource, _
        DestinationFile:=strDestination)
    '压缩完成后删除原文件
    Kill strSource
    '把压缩后的文件名改成原文件名
    Name strDestination As strSource
   
   
    On Error GoTo 0
    Exit Function
   
error_handler:
    RepairDatabase = False

End Function



最新评论

相关分类

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-28 10:11 , Processed in 0.059177 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部