Compacting BackEnd

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I'm trying to compact my backend from my frontend.
I found this code, but am having trouble adapting it.
I'm getting a path error on......Name strOldFile As strNewFile



Me.TxtFile = (Len(Dir$("C:\ProServ\DB\ADatabasebe.ldb")))
If Me.TxtFile>=1 Then
Dim strNewFile As String
Dim strOldFile As String
Dim strOldFileWithoutMDB As String
strNewFile = strOldFileWithoutMDB & Format$(Date, "yyyymmdd") & "
.MDB)"
Name strOldFile As strNewFile
DBEngine.CompactDatabase strNewFile, strOldFile
DoCmd.OpenForm "Form2"
Elseif Me.TxtFile = 0 Then
msgbox "USERS"
End If

Any help is appreciated.
Thanks
DS
 
Take a look at what's in strOldFile. You'll find it's got ";DATABASE=" in
front of it. Try:

strOldFile = Mid$(CurrentDb().TableDefs("table1").Connect, 11)

Where are you setting strOldFileWithoutMDB?
 
DS wrote:
I'm getting close....
I now get Invalid procedjure call or argument... Error #5
This is on the NAME strOldFile As StrNewFile

My FrontEnd is named ADatabase.mdb
And my Backend is ADatabasebe.mdb

Dim strNewFile As String
Dim strOldFile As String
Dim strOldFileWithoutMDB As String

strOldFile = CurrentDb().TableDefs("table1").Connect
Me.TxtFile = Len("C:\PROSERV\OLDSTUFF\ADatabasebe.ldb")
If Me.TxtFile >= 1 Then 'will equal 0 if the file doesn't exist)
strNewFile = strOldFileWithoutMDB & Format$(Date, "yyyymmdd") & " .MDB)"
Name strOldFile As strNewFile
DBEngine.CompactDatabase strNewFile, strOldFile
DoCmd.OpenForm "Form2"
ElseIf Me.TxtFile = 0 Then
MsgBox "CAN'T"
End If
 
Douglas said:
Take a look at what's in strOldFile. You'll find it's got ";DATABASE=" in
front of it. Try:

strOldFile = Mid$(CurrentDb().TableDefs("table1").Connect, 11)

Where are you setting strOldFileWithoutMDB?
Nowhere I guess? Any sugestions where?
Thanks
DS
 
Back
Top