Jeg havde nok valgt at skrive kode til at indsætte data i databasen via en VB applikation, syntaxen er næsten lige som VBA og der kan man netop anvende alle mulighederne for komprimere databasen.
You can use this to compact another dBFunction CompactDb(strDbPath As String) As Boolean
' This procedure creates a backup copy of a database ' and then compacts it. ' ' Arguments: ' strDbPath: The path to the database to be compacted. ' ' Returns: ' A Boolean value indicating success or failure.
Dim dbs As Database Dim intLength As Integer Dim varPosition As Variant Dim strDbTemp As String, strDbCompacted As String Dim strDbBackup As String Dim strMsg As String Const conPermissionDenied As Integer = 70
On Error GoTo Err_CompactDb ' Initialize string for message. strMsg = "Database " & strDbPath & " cannot be opened exclusively. " _ & "The database may have already been opened by you or another user."
' Compact the database to a temporary file. intLength = Len(strDbPath) varPosition = InStr(strDbPath, ".mdb") If varPosition > 0 Then strDbTemp = Left(strDbPath, varPosition - 1)
' Check whether database can be opened exclusively. ' This line calls a function defined in Chapter 2. If Not CanOpenDbExclusively(strDbPath) Then MsgBox strMsg GoTo Exit_CompactDb End If
' Compact to new file. strDbCompacted = strDbTemp & "Compacted.mdb" DBEngine.CompactDatabase strDbPath, strDbCompacted
' Delete uncompacted database. Kill strDbPath
' Rename compacted database to original name. Name strDbCompacted As strDbPath End If CompactDb = True
Exit_CompactDb: On Error Resume Next dbs.Close Set dbs = Nothing Exit Function
Err_CompactDb: If Err = conPermissionDenied Then MsgBox strMsg Else MsgBox "Error " & Err & ": " & vbCrLf & Err.Description End If CompactDb = False Resume Exit_CompactDb End Function
Godt link der, Terry :-) Det burde få løst jensens problemer. Det er dog træls at microsoft har været så usmarte at man ikke kan kompimere en åben DB
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.