A
AccessHelp
Good morning,
I have the following code to compact and repair the BE database just
clicking a button on the form of a FE database.
On Error goto Error_Handler
Dim strSource as string
Dim strDestination as string
strSource = "C:\T&T.mdb"
strDestination = "C:\T&T1.mdb"
CompactRepair = Application.CompactRepair (SourceFile:=strSource,
DestinationFile:= strDestination, LogFile:=True)
Kill strSource
Name strDestination As strSource
On Error goto 0
Exit sub
Error_Handler:
CompactRepair = False
Msgbox "The compacting of the database was not done. Please try again."
End sub
The code seems to work up to the point "CompactRepair = Application....".
It created a destination file and deleted the original source file. However,
instead of naming the destination file "T&T1.mdb", it names "T_T1.mdb".
Therefore, when it gets to the code "Name strDestination As strSource", it
failed because it couldn't find a file name "T&T1.mdb".
Does anyone know why Access uses "_" in place of "&"? How can I make the
code to accept "&" for the destination name?
In addition, according to the code, a log file should be created. I saw it
created then deleted itself. Anyone knows why?
On the other hand, if you have a better code to compact & repair the BE from
FE, please share with me.
Thanks.
I have the following code to compact and repair the BE database just
clicking a button on the form of a FE database.
On Error goto Error_Handler
Dim strSource as string
Dim strDestination as string
strSource = "C:\T&T.mdb"
strDestination = "C:\T&T1.mdb"
CompactRepair = Application.CompactRepair (SourceFile:=strSource,
DestinationFile:= strDestination, LogFile:=True)
Kill strSource
Name strDestination As strSource
On Error goto 0
Exit sub
Error_Handler:
CompactRepair = False
Msgbox "The compacting of the database was not done. Please try again."
End sub
The code seems to work up to the point "CompactRepair = Application....".
It created a destination file and deleted the original source file. However,
instead of naming the destination file "T&T1.mdb", it names "T_T1.mdb".
Therefore, when it gets to the code "Name strDestination As strSource", it
failed because it couldn't find a file name "T&T1.mdb".
Does anyone know why Access uses "_" in place of "&"? How can I make the
code to accept "&" for the destination name?
In addition, according to the code, a log file should be created. I saw it
created then deleted itself. Anyone knows why?
On the other hand, if you have a better code to compact & repair the BE from
FE, please share with me.
Thanks.