In my archive folders, I found the beginning and the end of the code I am looking for. But this is not the final version, and I miss the middle of the code...
Here it is in case it helps :
Code:
Option Compare Database
'--------------
Public Sub CompactAll()
'--------------
cycleThruAllFilesInDir "G:\Nico\Desktop\Test\"
End Sub
'--------------
Public Sub cycleThruAllFilesInDir(ByVal pvDir)
'--------------
Dim FSO, oFolder, oFile, vFile
Dim sTxt As String, sFile As String
Dim acc As Access.Application
Dim control As Office.CommandBarControl
Dim bRun As Boolean
Dim i As Integer
On Error GoTo errGetFiles
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = FSO.GetFolder(pvDir)
Set acc = New Access.Application
For Each oFile In oFolder.Files
bRun = False
If (InStr(oFile.Name, ".accdb") > 0) Or (InStr(oFile.Name, ".mdb") > 0) Then
'verify its a db file
If (InStr(oFile.Name, ".accdb") > 0) Then
i = InStr(oFile.Name, ".accdb")
If i = Len(oFile.Name) - 5 Then bRun = True
Else
i = InStr(oFile.Name, ".mdb")
If i = Len(oFile.Name) - 3 Then bRun = True
End If
XXXX missing code XXXX
End If
Next
endit:
Set oFile = Nothing
Set oFolder = Nothing
Set FSO = Nothing
Set acc = Nothing
Set control = Nothing
MsgBox "Done"
Exit Sub
errGetFiles:
MsgBox Err.Description, , Err
Resume endit
End Sub
There may even be some mistakes in this code I found, I don't know.
I think the missing code is the part where it added the primary key.