Hi all,
I'm having a problem, repairing/compacting an MS Aceess 97 MDB from VB6 with the following code. It just doesn't work on one PC with a DAO error 3125, "<Name> is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long." The code works just fine on other PC's, but not on this one. The PC is Windows 2000 Pro with Access 2003 installed. Can I not use the DAO compact method if MS Access 2003 is installed?
Thank you for helping.
Regards,
Hideki
Public Sub gufCompactDB()
Dim intFileNameLen As Integer
Dim strLDB As String
Dim strCompactedFile As String
intFileNameLen = Len(gstrADO_DATASOURCE)
strLDB = Left(gstrADO_DATASOURCE, intFileNameLen - 3) & "ldb"
strCompactedFile = Left(gstrADO_DATASOURCE, intFileNameLen - 3) & "cmp"
If Len(Dir(strLDB)) = 0 Then
On Error GoTo ERROR_HANDLER
'Repairing
DBEngine.RepairDatabase gstrADO_DATASOURCE
'Compacting
DBEngine.CompactDatabase gstrADO_DATASOURCE, _
strCompactedFile
'Replacing with compacted data
Kill gstrADO_DATASOURCE
Name strCompactedFile As gstrADO_DATASOURCE
On Error GoTo 0
End If
Exit Sub
ERROR_HANDLER:
MsgBox "The system cannot optimize the data file due to the following error." & vbCrLf & vbCrLf & Err.Number & " " & Err.Description _
, vbExclamation, gstrMsgTitle
End Sub
I'm having a problem, repairing/compacting an MS Aceess 97 MDB from VB6 with the following code. It just doesn't work on one PC with a DAO error 3125, "<Name> is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long." The code works just fine on other PC's, but not on this one. The PC is Windows 2000 Pro with Access 2003 installed. Can I not use the DAO compact method if MS Access 2003 is installed?
Thank you for helping.
Regards,
Hideki
Public Sub gufCompactDB()
Dim intFileNameLen As Integer
Dim strLDB As String
Dim strCompactedFile As String
intFileNameLen = Len(gstrADO_DATASOURCE)
strLDB = Left(gstrADO_DATASOURCE, intFileNameLen - 3) & "ldb"
strCompactedFile = Left(gstrADO_DATASOURCE, intFileNameLen - 3) & "cmp"
If Len(Dir(strLDB)) = 0 Then
On Error GoTo ERROR_HANDLER
'Repairing
DBEngine.RepairDatabase gstrADO_DATASOURCE
'Compacting
DBEngine.CompactDatabase gstrADO_DATASOURCE, _
strCompactedFile
'Replacing with compacted data
Kill gstrADO_DATASOURCE
Name strCompactedFile As gstrADO_DATASOURCE
On Error GoTo 0
End If
Exit Sub
ERROR_HANDLER:
MsgBox "The system cannot optimize the data file due to the following error." & vbCrLf & vbCrLf & Err.Number & " " & Err.Description _
, vbExclamation, gstrMsgTitle
End Sub