Discussione: Vba Aiuto!!!
View Single Post
Old 19-09-2002, 13:00   #2
xegallo
Member
 
Iscritto dal: Jan 2001
Cittā: PATAVIUM
Messaggi: 280
Codice:
Function CompactAndRepairDatabase(DatabasePath As String, _
        Optional Password As String, _
        Optional TempFile As String = "c:\temp.mdb")
    If DBEngine.Version < "3.6" Then DBEngine.RepairDatabase DatabasePath
    'if no temp file specified, use "c:\temp.mdb"
    If TempFile = "" Then TempFile = "c:\temp.mdb"
    
    'delete temp file if it exists
    If Dir(TempFile) <> "" Then Kill TempFile
    
    'format password in form of ";pwd=PASSWORD" if password exists
    If Password <> "" Then Password = ";pwd=" & Password
    
    'compact db: a new db will be created
    DBEngine.CompactDatabase DatabasePath, TempFile, , , Password
    
    'kill first db
    Kill DatabasePath
    
    'move compacted db to original db's path
    FileCopy TempFile, DatabasePath
    
    'delete temp file
    Kill TempFile
End Function
__________________
Salva il Pianeta
xegallo č offline   Rispondi citando il messaggio o parte di esso