Compacting BackEnd

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
 
D

Douglas J. Steele

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?
 
D

DS

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
 
D

DS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top